]> git.sesse.net Git - vlc/blob - bindings/java/src/main/java/org/videolan/jvlc/MediaList.java
remove old headers in java bindings
[vlc] / bindings / java / src / main / java / org / videolan / jvlc / MediaList.java
1 /*****************************************************************************
2  * MediaList.java: VLC Java Bindings, MediaList
3  *****************************************************************************
4  * Copyright (C) 1998-2008 the VideoLAN team
5  *
6  * Authors: Filippo Carone <filippo@carone.org>
7  *
8  *
9  * $Id $
10  *
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.
15  *
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.
20  *
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  *****************************************************************************/
25
26 package org.videolan.jvlc;
27
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;
32
33
34 public class MediaList
35 {
36
37     private final JVLC jvlc;
38
39     private final LibVlcMediaList instance;
40
41     private final LibVlcEventManager eventManager;
42
43     public MediaList(JVLC jvlc)
44     {
45         this.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);
49     }
50
51     public void addMedia(String media)
52     {
53         MediaDescriptor descriptor = new MediaDescriptor(jvlc, media);
54         addMediaDescriptor(descriptor);
55     }
56
57     public void addMediaDescriptor(MediaDescriptor descriptor)
58     {
59         libvlc_exception_t exception = new libvlc_exception_t();
60         jvlc.getLibvlc().libvlc_media_list_add_media_descriptor(instance, descriptor.getInstance(), exception);
61     }
62
63     public int itemsCount()
64     {
65         libvlc_exception_t exception = new libvlc_exception_t();
66         return jvlc.getLibvlc().libvlc_media_list_count(instance, exception);
67     }
68
69     public int indexOf(MediaDescriptor descriptor)
70     {
71         libvlc_exception_t exception = new libvlc_exception_t();
72         return jvlc.getLibvlc().libvlc_media_list_index_of_item(instance, descriptor.getInstance(), exception);
73     }
74
75     public MediaDescriptor getMediaDescriptorAtIndex(int index)
76     {
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);
80     }
81
82     public void remove(int index)
83     {
84         libvlc_exception_t exception = new libvlc_exception_t();
85         jvlc.getLibvlc().libvlc_media_list_remove_index(instance, index, exception);
86     }
87
88     public void insertMediaDescriptor(MediaDescriptor descriptor, int index)
89     {
90         libvlc_exception_t exception = new libvlc_exception_t();
91         jvlc
92             .getLibvlc()
93             .libvlc_media_list_insert_media_descriptor(instance, descriptor.getInstance(), index, exception);
94     }
95
96     /**
97      * {@inheritDoc}
98      */
99     @Override
100     protected void finalize() throws Throwable
101     {
102         jvlc.getLibvlc().libvlc_media_list_release(instance);
103         super.finalize();
104     }
105
106     /**
107      * Returns the instance.
108      * @return the instance
109      */
110     LibVlcMediaList getInstance()
111     {
112         return instance;
113     }
114
115 }