]> git.sesse.net Git - vlc/blob - src/control/playlist.c
Do not use non-existing function playlist_PlaylistAddExt.
[vlc] / src / control / playlist.c
1 /*****************************************************************************
2  * playlist.c: libvlc new API playlist handling functions
3  *****************************************************************************
4  * Copyright (C) 2005 the VideoLAN team
5  * $Id$
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #include <libvlc_internal.h>
25 #include <vlc/libvlc.h>
26
27 #include <vlc/intf.h>
28
29 #include <assert.h>
30
31 #define PL p_instance->p_libvlc_int->p_playlist
32
33 void libvlc_playlist_loop( libvlc_instance_t *p_instance, vlc_bool_t loop,
34                            libvlc_exception_t *p_e)
35 {
36     assert( PL );
37     var_SetBool(PL,"loop",loop);
38 }
39
40 void libvlc_playlist_play( libvlc_instance_t *p_instance, int i_id,
41                            int i_options, char **ppsz_options,
42                            libvlc_exception_t *p_e )
43 {
44     assert( PL );
45     ///\todo Handle additionnal options
46
47     if( PL->items.i_size == 0 ) RAISEVOID( "Empty playlist" );
48     if( i_id > 0 )
49     {
50         playlist_item_t *p_item = playlist_ItemGetById( PL,
51                                                         i_id );
52         if( !p_item ) RAISEVOID( "Unable to find item" );
53
54         playlist_LockControl( PL, PLAYLIST_VIEWPLAY,
55                               PL->status.p_node, p_item );
56     }
57     else
58     {
59         playlist_Play( PL );
60     }
61 }
62
63 void libvlc_playlist_pause( libvlc_instance_t *p_instance,
64                            libvlc_exception_t *p_e )
65 {
66     assert( PL );
67     if( playlist_Pause( PL ) != VLC_SUCCESS )
68         RAISEVOID( "Empty playlist" );
69 }
70
71
72 void libvlc_playlist_stop( libvlc_instance_t *p_instance,
73                            libvlc_exception_t *p_e )
74 {
75     assert( PL );
76     if( playlist_Stop( PL ) != VLC_SUCCESS )
77         RAISEVOID( "Empty playlist" );
78 }
79
80 void libvlc_playlist_clear( libvlc_instance_t *p_instance,
81                            libvlc_exception_t *p_e )
82 {
83     assert( PL );
84     playlist_LockClear( PL );
85 }
86
87 void libvlc_playlist_next( libvlc_instance_t *p_instance,
88                            libvlc_exception_t *p_e )
89 {
90     assert( PL );
91     if( playlist_Next( PL ) != VLC_SUCCESS )
92         RAISEVOID( "Empty playlist" );
93 }
94
95 void libvlc_playlist_prev( libvlc_instance_t *p_instance,
96                            libvlc_exception_t *p_e )
97 {
98     if( playlist_Prev( PL ) != VLC_SUCCESS )
99         RAISEVOID( "Empty playlist" );
100 }
101
102 int libvlc_playlist_add( libvlc_instance_t *p_instance, const char *psz_uri,
103                          const char *psz_name, libvlc_exception_t *p_e )
104 {
105     return libvlc_playlist_add_extended( p_instance, psz_uri, psz_name,
106                                          0, NULL, p_e );
107 }
108
109 int libvlc_playlist_add_extended( libvlc_instance_t *p_instance,
110                                   const char *psz_uri, const char *psz_name,
111                                   int i_options, const char **ppsz_options,
112                                   libvlc_exception_t *p_e )
113 {
114     assert( PL );
115 #ifndef FIXME
116     return VLC_EGENERIC;
117 #else
118     return playlist_PlaylistAddExt( PL, psz_uri, psz_name,
119                             PLAYLIST_INSERT, PLAYLIST_END, -1, ppsz_options,
120                             i_options );
121 #endif
122 }
123
124 int libvlc_playlist_delete_item( libvlc_instance_t *p_instance, int i_id,
125                                  libvlc_exception_t *p_e )
126 {
127     assert( PL );
128     return playlist_DeleteFromItemId( PL, i_id );
129 }
130
131
132 int libvlc_playlist_isplaying( libvlc_instance_t *p_instance,
133                                libvlc_exception_t *p_e )
134 {
135     assert( PL );
136     return playlist_IsPlaying( PL );
137 }
138
139 int libvlc_playlist_items_count( libvlc_instance_t *p_instance,
140                                  libvlc_exception_t *p_e )
141 {
142     assert( PL );
143     return PL->items.i_size;
144 }
145
146 libvlc_input_t * libvlc_playlist_get_input( libvlc_instance_t *p_instance,
147                                             libvlc_exception_t *p_e )
148 {
149     libvlc_input_t *p_input;
150     assert( PL );
151
152     vlc_mutex_lock( &PL->object_lock );
153     if( PL->p_input == NULL )
154     {
155         libvlc_exception_raise( p_e, "No active input" );
156         vlc_mutex_unlock( &PL->object_lock );
157         return NULL;
158     }
159     p_input = (libvlc_input_t *)malloc( sizeof( libvlc_input_t ) );
160
161     p_input->i_input_id = PL->p_input->i_object_id;
162     p_input->p_instance = p_instance;
163     vlc_mutex_unlock( &PL->object_lock );
164
165     return p_input;
166 }