]> git.sesse.net Git - vlc/blob - bindings/java/org/videolan/jvlc/Playlist.java
deprecate playlist
[vlc] / bindings / java / org / videolan / jvlc / Playlist.java
1  /*****************************************************************************
2  * Playlist.java: PlaylistIntf implementation class
3  *****************************************************************************
4  *
5  * Copyright (C) 1998-2008 the VideoLAN team
6  * 
7  * Author: Filippo Carone <filippo@carone.org>
8  *
9  * Created on 28-feb-2006
10  *
11  * $Id: Playlist.java 17089 2006-10-15 10:54:15Z littlejohn $
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 import org.videolan.jvlc.internal.LibVlc;
33 import org.videolan.jvlc.internal.LibVlc.LibVlcInstance;
34 import org.videolan.jvlc.internal.LibVlc.LibVlcMediaInstance;
35 import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t;
36
37 /**
38  * The playlist is deprecated and will be removed. Use MediaList and MediaListPlayer instead.
39  */
40 @Deprecated
41 public class Playlist {
42     
43     
44     private final LibVlcInstance libvlcInstance;
45     private final LibVlc libvlc;
46     private final JVLC jvlc;
47
48     public Playlist(JVLC jvlc) {
49         this.jvlc = jvlc;
50         this.libvlcInstance = jvlc.getInstance();
51         this.libvlc = jvlc.getLibvlc();
52     }
53     
54     public synchronized void play(int id, String[] options) throws VLCException {
55         libvlc_exception_t exception = new libvlc_exception_t();
56         libvlc.libvlc_playlist_play(libvlcInstance, id, options.length, options, exception);
57     }
58
59     public synchronized void play() throws VLCException {
60         libvlc_exception_t exception = new libvlc_exception_t();
61         libvlc.libvlc_playlist_play(libvlcInstance, -1, 0, new String[] {}, exception);
62     }
63
64     public synchronized void togglePause() throws VLCException {
65         libvlc_exception_t exception = new libvlc_exception_t();
66         libvlc.libvlc_playlist_pause(libvlcInstance, exception);
67     }
68
69     public synchronized void stop() throws VLCException {
70         libvlc_exception_t exception = new libvlc_exception_t();
71         libvlc.libvlc_playlist_stop(libvlcInstance, exception);
72     }
73
74     public boolean isRunning() throws VLCException {
75         libvlc_exception_t exception = new libvlc_exception_t();
76         return libvlc.libvlc_playlist_isplaying(libvlcInstance, exception) == 0? false : true;
77     }
78
79     public synchronized int itemsCount() throws VLCException {
80         libvlc_exception_t exception = new libvlc_exception_t();
81         return libvlc.libvlc_playlist_items_count(libvlcInstance, exception);
82     }
83
84     public synchronized void next() throws VLCException {
85         libvlc_exception_t exception = new libvlc_exception_t();
86         if (! isRunning())
87             play();
88         libvlc.libvlc_playlist_next(libvlcInstance, exception);
89     }
90
91     public synchronized void prev() throws VLCException {
92         libvlc_exception_t exception = new libvlc_exception_t();
93         if (! isRunning())
94             play();
95         libvlc.libvlc_playlist_prev(libvlcInstance, exception);
96     }
97
98     public synchronized void clear() throws VLCException {
99         libvlc_exception_t exception = new libvlc_exception_t();
100         libvlc.libvlc_playlist_clear(libvlcInstance, exception);
101     }
102     
103     public synchronized int add(String uri, String name) throws VLCException {
104         libvlc_exception_t exception = new libvlc_exception_t();
105         return libvlc.libvlc_playlist_add(libvlcInstance, uri, name, exception);
106     }
107
108
109     public synchronized void deleteItem(int itemID) throws VLCException {
110         libvlc_exception_t exception = new libvlc_exception_t();
111         libvlc.libvlc_playlist_delete_item(libvlcInstance, itemID, exception);
112     }
113     
114     public synchronized void setLoop(boolean loop) {
115         libvlc_exception_t exception = new libvlc_exception_t();
116         libvlc.libvlc_playlist_loop(libvlcInstance, loop? 1 : 0, exception);
117     }
118     
119     public MediaInstance getMediaInstance()
120     {
121         libvlc_exception_t exception = new libvlc_exception_t();
122         LibVlcMediaInstance mi = libvlc.libvlc_playlist_get_media_instance(libvlcInstance, exception);
123         return new MediaInstance(jvlc, mi);
124         
125     }
126 }