1 /*****************************************************************************
2 * Playlist.java: PlaylistIntf implementation class
3 *****************************************************************************
5 * Copyright (C) 1998-2008 the VideoLAN team
7 * Author: Filippo Carone <filippo@carone.org>
9 * Created on 28-feb-2006
11 * $Id: Playlist.java 17089 2006-10-15 10:54:15Z littlejohn $
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.
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.
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.
30 package org.videolan.jvlc;
32 import org.videolan.jvlc.internal.LibVlc;
33 import org.videolan.jvlc.internal.LibVlc.LibVlcInstance;
34 import org.videolan.jvlc.internal.LibVlc.LibVlcMediaPlayer;
35 import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t;
38 * The playlist is deprecated and will be removed. Use MediaList and MediaListPlayer instead.
41 public class Playlist {
44 private final LibVlcInstance libvlcInstance;
45 private final LibVlc libvlc;
46 private final JVLC jvlc;
48 public Playlist(JVLC jvlc) {
50 this.libvlcInstance = jvlc.getInstance();
51 this.libvlc = jvlc.getLibvlc();
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);
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);
64 public synchronized void togglePause() throws VLCException {
65 libvlc_exception_t exception = new libvlc_exception_t();
66 libvlc.libvlc_playlist_pause(libvlcInstance, exception);
69 public synchronized void stop() throws VLCException {
70 libvlc_exception_t exception = new libvlc_exception_t();
71 libvlc.libvlc_playlist_stop(libvlcInstance, exception);
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;
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);
84 public synchronized void next() throws VLCException {
85 libvlc_exception_t exception = new libvlc_exception_t();
88 libvlc.libvlc_playlist_next(libvlcInstance, exception);
91 public synchronized void prev() throws VLCException {
92 libvlc_exception_t exception = new libvlc_exception_t();
95 libvlc.libvlc_playlist_prev(libvlcInstance, exception);
98 public synchronized void clear() throws VLCException {
99 libvlc_exception_t exception = new libvlc_exception_t();
100 libvlc.libvlc_playlist_clear(libvlcInstance, exception);
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);
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);
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);
119 public MediaPlayer getMediaInstance()
121 libvlc_exception_t exception = new libvlc_exception_t();
122 LibVlcMediaPlayer mi = libvlc.libvlc_playlist_get_media_player(libvlcInstance, exception);
123 return new MediaPlayer(jvlc, mi);