1 /*****************************************************************************
2 * playlist.c: libvlc new API playlist handling functions
3 *****************************************************************************
4 * Copyright (C) 2005 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
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.
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.
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 *****************************************************************************/
24 #include <libvlc_internal.h>
25 #include <vlc/libvlc.h>
31 #define PL p_instance->p_libvlc_int->p_playlist
33 void libvlc_playlist_play( libvlc_instance_t *p_instance, int i_id,
34 int i_options, char **ppsz_options,
35 libvlc_exception_t *p_e )
38 ///\todo Handle additionnal options
40 if( PL->i_size == 0 ) RAISEVOID( "Empty playlist" );
43 playlist_item_t *p_item = playlist_ItemGetById( PL,
45 if( !p_item ) RAISEVOID( "Unable to find item" );
47 playlist_LockControl( PL, PLAYLIST_VIEWPLAY,
48 PL->status.p_node, p_item );
56 void libvlc_playlist_pause( libvlc_instance_t *p_instance,
57 libvlc_exception_t *p_e )
60 if( playlist_Pause( PL ) != VLC_SUCCESS )
61 RAISEVOID( "Empty playlist" );
65 void libvlc_playlist_stop( libvlc_instance_t *p_instance,
66 libvlc_exception_t *p_e )
69 if( playlist_Stop( PL ) != VLC_SUCCESS )
70 RAISEVOID( "Empty playlist" );
73 void libvlc_playlist_clear( libvlc_instance_t *p_instance,
74 libvlc_exception_t *p_e )
80 void libvlc_playlist_next( libvlc_instance_t *p_instance,
81 libvlc_exception_t *p_e )
84 if( playlist_Next( PL ) != VLC_SUCCESS )
85 RAISEVOID( "Empty playlist" );
88 void libvlc_playlist_prev( libvlc_instance_t *p_instance,
89 libvlc_exception_t *p_e )
91 if( playlist_Prev( PL ) != VLC_SUCCESS )
92 RAISEVOID( "Empty playlist" );
95 int libvlc_playlist_add( libvlc_instance_t *p_instance, const char *psz_uri,
96 const char *psz_name, libvlc_exception_t *p_e )
98 return libvlc_playlist_add_extended( p_instance, psz_uri, psz_name,
102 int libvlc_playlist_add_extended( libvlc_instance_t *p_instance,
103 const char *psz_uri, const char *psz_name,
104 int i_options, const char **ppsz_options,
105 libvlc_exception_t *p_e )
108 return playlist_PlaylistAddExt( PL, psz_uri, psz_name,
109 PLAYLIST_INSERT, PLAYLIST_END, -1, ppsz_options,
113 int libvlc_playlist_delete_item( libvlc_instance_t *p_instance, int i_id,
114 libvlc_exception_t *p_e )
117 return playlist_DeleteFromItemId( PL, i_id );
121 int libvlc_playlist_isplaying( libvlc_instance_t *p_instance,
122 libvlc_exception_t *p_e )
125 return playlist_IsPlaying( PL );
128 int libvlc_playlist_items_count( libvlc_instance_t *p_instance,
129 libvlc_exception_t *p_e )
135 libvlc_input_t * libvlc_playlist_get_input( libvlc_instance_t *p_instance,
136 libvlc_exception_t *p_e )
138 libvlc_input_t *p_input;
141 vlc_mutex_lock( &PL->object_lock );
142 if( PL->p_input == NULL )
144 libvlc_exception_raise( p_e, "No active input" );
145 vlc_mutex_unlock( &PL->object_lock );
148 p_input = (libvlc_input_t *)malloc( sizeof( libvlc_input_t ) );
150 p_input->i_input_id = PL->p_input->i_object_id;
151 p_input->p_instance = p_instance;
152 vlc_mutex_unlock( &PL->object_lock );