]> git.sesse.net Git - vlc/blob - bindings/java/org/videolan/jvlc/Playlist.java
82626433acb95d263897b27ee6ebc57373c98d10
[vlc] / bindings / java / org / videolan / jvlc / Playlist.java
1  /*****************************************************************************
2  * Playlist.java: PlaylistIntf implementation class
3  *****************************************************************************
4  *
5  * Copyright (C) 1998-2006 the VideoLAN team
6  * 
7  * Author: Filippo Carone <filippo@carone.org>
8  *
9  * Created on 28-feb-2006
10  *
11  * $Id$
12  *
13  * This program is free software; you can redistribute it
14  * and/or modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2 of the
16  * License, or (at your option) any later version.
17  * 
18  * This program is distributed in the hope that it will be useful, but
19  * WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21  * General Public License for more details.
22  * 
23  * You should have received a copy of the GNU General Public
24  * License along with this program; if not, write to the Free Software
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
26  * 
27  */
28
29
30 package org.videolan.jvlc;
31
32 public class Playlist implements PlaylistIntf {
33     
34     
35     private long libvlcInstance;
36
37     public Playlist(long _libvlcInstance) {
38         this.libvlcInstance = _libvlcInstance;
39     }
40     
41     native private int _playlist_add(String uri, String name, String[] options);
42     native private void _play(int _id, String[] options);
43     native private void _pause();
44     native private void _stop();
45     native private void _next();
46     native private void _prev();
47     native private void _clear();
48     native private void _deleteItem(int itemID);
49     
50     native private int _itemsCount();
51     native private int _isRunning();
52     native private void _setLoop(boolean loop);
53
54
55     public synchronized void play(int id, String[] options) throws VLCException {
56         _play(id, options);
57     }
58
59     public synchronized void play() throws VLCException {
60         play(-1, null);
61     }
62
63     public synchronized void togglePause() throws VLCException {
64         _pause();
65     }
66
67     public synchronized void stop() throws VLCException {
68         _stop();
69 //        do {
70 //              try {
71 //                              Thread.sleep(50);
72 //                      } catch (InterruptedException e) {
73 //                              e.printStackTrace();
74 //                      }
75 //        } while (isRunning());
76     }
77
78     public boolean isRunning() throws VLCException {
79          return (_isRunning() == 0)? false : true ;
80     }
81
82     public synchronized int itemsCount() throws VLCException {
83         return _itemsCount();
84     }
85
86     public synchronized void next() throws VLCException {
87         if (! isRunning())
88             play();
89         _next();
90     }
91
92     public synchronized void prev() throws VLCException {
93         if (! isRunning())
94             play();
95         _prev();
96     }
97
98     public synchronized void clear() throws VLCException {
99         _clear();
100     }
101
102     public synchronized int add(String uri, String name, String[] options) throws VLCException {
103         return _playlist_add(uri, name, options);
104     }
105     
106     public synchronized int add(String uri, String name) throws VLCException {
107         return add(uri, name, null);
108     }
109
110     public synchronized void addExtended() {
111     }
112
113     public synchronized void deleteItem(int itemID) throws VLCException {
114         _deleteItem(itemID);
115     }
116     
117     public synchronized void setLoop(boolean loop) {
118         _setLoop(loop);
119     }
120     
121     public long getInstance() throws VLCException {
122         return libvlcInstance;
123     }
124
125         public void setPause(boolean pause) throws VLCException {
126                 // TODO Auto-generated method stub              
127         }
128
129 }