]> git.sesse.net Git - vlc/blob - bindings/java/org/videolan/jvlc/Playlist.java
0d007efbe742e6ddd790506d298f778c29fefe99
[vlc] / bindings / java / org / videolan / jvlc / Playlist.java
1  /*****************************************************************************
2  * PlaylistIntf.java: The playlist interface
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     
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
70     }
71
72     public boolean isRunning() throws VLCException {
73          return (_isRunning() == 0)? false : true ;
74     }
75
76     public synchronized int itemsCount() throws VLCException {
77         return _itemsCount();
78     }
79
80     public synchronized void next() throws VLCException {
81         if (! isRunning())
82             play();
83         _next();
84     }
85
86     public synchronized void prev() throws VLCException {
87         if (! isRunning())
88             play();
89         _prev();
90     }
91
92     public synchronized void clear() throws VLCException {
93         _clear();
94     }
95
96     public synchronized int add(String uri, String name, String[] options) throws VLCException {
97         return _playlist_add(uri, name, options);
98     }
99     
100     public synchronized int add(String uri, String name) throws VLCException {
101         return add(uri, name, null);
102     }
103
104     public synchronized void addExtended() {
105     }
106
107     public synchronized void deleteItem(int itemID) throws VLCException {
108         _deleteItem(itemID);
109     }
110     
111     public long getInstance() throws VLCException {
112         return libvlcInstance;
113     }
114 }