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.LibVlcMediaInstance;
35 import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t;
37 public class Playlist {
40 private final LibVlcInstance libvlcInstance;
41 private final LibVlc libvlc;
42 private final JVLC jvlc;
44 public Playlist(JVLC jvlc) {
46 this.libvlcInstance = jvlc.getInstance();
47 this.libvlc = jvlc.getLibvlc();
50 public synchronized void play(int id, String[] options) throws VLCException {
51 libvlc_exception_t exception = new libvlc_exception_t();
52 libvlc.libvlc_playlist_play(libvlcInstance, id, options.length, options, exception);
55 public synchronized void play() throws VLCException {
56 libvlc_exception_t exception = new libvlc_exception_t();
57 libvlc.libvlc_playlist_play(libvlcInstance, -1, 0, new String[] {}, exception);
60 public synchronized void togglePause() throws VLCException {
61 libvlc_exception_t exception = new libvlc_exception_t();
62 libvlc.libvlc_playlist_pause(libvlcInstance, exception);
65 public synchronized void stop() throws VLCException {
66 libvlc_exception_t exception = new libvlc_exception_t();
67 libvlc.libvlc_playlist_stop(libvlcInstance, exception);
70 public boolean isRunning() throws VLCException {
71 libvlc_exception_t exception = new libvlc_exception_t();
72 return libvlc.libvlc_playlist_isplaying(libvlcInstance, exception) == 0? false : true;
75 public synchronized int itemsCount() throws VLCException {
76 libvlc_exception_t exception = new libvlc_exception_t();
77 return libvlc.libvlc_playlist_items_count(libvlcInstance, exception);
80 public synchronized void next() throws VLCException {
81 libvlc_exception_t exception = new libvlc_exception_t();
84 libvlc.libvlc_playlist_next(libvlcInstance, exception);
87 public synchronized void prev() throws VLCException {
88 libvlc_exception_t exception = new libvlc_exception_t();
91 libvlc.libvlc_playlist_prev(libvlcInstance, exception);
94 public synchronized void clear() throws VLCException {
95 libvlc_exception_t exception = new libvlc_exception_t();
96 libvlc.libvlc_playlist_clear(libvlcInstance, exception);
99 public synchronized int add(String uri, String name) throws VLCException {
100 libvlc_exception_t exception = new libvlc_exception_t();
101 return libvlc.libvlc_playlist_add(libvlcInstance, uri, name, exception);
105 public synchronized void deleteItem(int itemID) throws VLCException {
106 libvlc_exception_t exception = new libvlc_exception_t();
107 libvlc.libvlc_playlist_delete_item(libvlcInstance, itemID, exception);
110 public synchronized void setLoop(boolean loop) {
111 libvlc_exception_t exception = new libvlc_exception_t();
112 libvlc.libvlc_playlist_loop(libvlcInstance, loop? 1 : 0, exception);
115 public MediaInstance getMediaInstance()
117 libvlc_exception_t exception = new libvlc_exception_t();
118 LibVlcMediaInstance mi = libvlc.libvlc_playlist_get_media_instance(libvlcInstance, exception);
119 return new MediaInstance(jvlc, mi);