1 /*****************************************************************************
2 * MediaList.java: VLC Java Bindings, MediaList
3 *****************************************************************************
4 * Copyright (C) 1998-2008 the VideoLAN team
6 * Authors: Filippo Carone <filippo@carone.org>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
24 *****************************************************************************/
26 package org.videolan.jvlc;
28 import org.videolan.jvlc.internal.LibVlc.LibVlcEventManager;
29 import org.videolan.jvlc.internal.LibVlc.LibVlcMediaDescriptor;
30 import org.videolan.jvlc.internal.LibVlc.LibVlcMediaList;
31 import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t;
34 public class MediaList
37 private final JVLC jvlc;
39 private final LibVlcMediaList instance;
41 private final LibVlcEventManager eventManager;
43 public MediaList(JVLC jvlc)
46 libvlc_exception_t exception = new libvlc_exception_t();
47 instance = jvlc.getLibvlc().libvlc_media_list_new(jvlc.getInstance(), exception);
48 eventManager = jvlc.getLibvlc().libvlc_media_list_event_manager(instance, exception);
51 public void addMedia(String media)
53 MediaDescriptor descriptor = new MediaDescriptor(jvlc, media);
54 addMediaDescriptor(descriptor);
57 public void addMediaDescriptor(MediaDescriptor descriptor)
59 libvlc_exception_t exception = new libvlc_exception_t();
60 jvlc.getLibvlc().libvlc_media_list_add_media_descriptor(instance, descriptor.getInstance(), exception);
63 public int itemsCount()
65 libvlc_exception_t exception = new libvlc_exception_t();
66 return jvlc.getLibvlc().libvlc_media_list_count(instance, exception);
69 public int indexOf(MediaDescriptor descriptor)
71 libvlc_exception_t exception = new libvlc_exception_t();
72 return jvlc.getLibvlc().libvlc_media_list_index_of_item(instance, descriptor.getInstance(), exception);
75 public MediaDescriptor getMediaDescriptorAtIndex(int index)
77 libvlc_exception_t exception = new libvlc_exception_t();
78 LibVlcMediaDescriptor descriptor = jvlc.getLibvlc().libvlc_media_list_item_at_index(instance, index, exception);
79 return new MediaDescriptor(jvlc, descriptor);
82 public void remove(int index)
84 libvlc_exception_t exception = new libvlc_exception_t();
85 jvlc.getLibvlc().libvlc_media_list_remove_index(instance, index, exception);
88 public void insertMediaDescriptor(MediaDescriptor descriptor, int index)
90 libvlc_exception_t exception = new libvlc_exception_t();
93 .libvlc_media_list_insert_media_descriptor(instance, descriptor.getInstance(), index, exception);
100 protected void finalize() throws Throwable
102 jvlc.getLibvlc().libvlc_media_list_release(instance);
107 * Returns the instance.
108 * @return the instance
110 LibVlcMediaList getInstance()