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>
26 #include <vlc_playlist.h>
30 #include "../playlist/playlist_internal.h"
32 #define PL p_instance->p_libvlc_int->p_playlist
34 void libvlc_playlist_loop( libvlc_instance_t *p_instance, vlc_bool_t loop,
35 libvlc_exception_t *p_e)
38 var_SetBool( PL, "loop", loop );
41 void libvlc_playlist_play( libvlc_instance_t *p_instance, int i_id,
42 int i_options, char **ppsz_options,
43 libvlc_exception_t *p_e )
46 ///\todo Handle additionnal options
48 if( PL->items.i_size == 0 ) RAISEVOID( "Empty playlist" );
51 playlist_item_t *p_item = playlist_ItemGetByInputId( PL, i_id,
53 if( !p_item ) RAISEVOID( "Unable to find item" );
55 playlist_Control( PL, PLAYLIST_VIEWPLAY, VLC_FALSE,
56 PL->status.p_node, p_item );
64 void libvlc_playlist_pause( libvlc_instance_t *p_instance,
65 libvlc_exception_t *p_e )
68 if( playlist_Pause( PL ) != VLC_SUCCESS )
69 RAISEVOID( "Empty playlist" );
73 void libvlc_playlist_stop( libvlc_instance_t *p_instance,
74 libvlc_exception_t *p_e )
77 if( playlist_Stop( PL ) != VLC_SUCCESS )
78 RAISEVOID( "Empty playlist" );
81 void libvlc_playlist_clear( libvlc_instance_t *p_instance,
82 libvlc_exception_t *p_e )
85 playlist_Clear( PL, VLC_FALSE );
88 void libvlc_playlist_next( libvlc_instance_t *p_instance,
89 libvlc_exception_t *p_e )
92 if( playlist_Next( PL ) != VLC_SUCCESS )
93 RAISEVOID( "Empty playlist" );
96 void libvlc_playlist_prev( libvlc_instance_t *p_instance,
97 libvlc_exception_t *p_e )
99 if( playlist_Prev( PL ) != VLC_SUCCESS )
100 RAISEVOID( "Empty playlist" );
103 int libvlc_playlist_add( libvlc_instance_t *p_instance, const char *psz_uri,
104 const char *psz_name, libvlc_exception_t *p_e )
106 return libvlc_playlist_add_extended( p_instance, psz_uri, psz_name,
110 int libvlc_playlist_add_extended( libvlc_instance_t *p_instance,
111 const char *psz_uri, const char *psz_name,
112 int i_options, const char **ppsz_options,
113 libvlc_exception_t *p_e )
116 return playlist_AddExt( PL, psz_uri, psz_name,
117 PLAYLIST_INSERT, PLAYLIST_END, -1, ppsz_options,
123 int libvlc_playlist_delete_item( libvlc_instance_t *p_instance, int i_id,
124 libvlc_exception_t *p_e )
128 if( playlist_DeleteFromInput( PL, i_id, VLC_FALSE ) )
130 libvlc_exception_raise( p_e, "deletion failed" );
136 int libvlc_playlist_isplaying( libvlc_instance_t *p_instance,
137 libvlc_exception_t *p_e )
140 return playlist_IsPlaying( PL );
143 int libvlc_playlist_items_count( libvlc_instance_t *p_instance,
144 libvlc_exception_t *p_e )
147 return PL->items.i_size;
150 libvlc_input_t * libvlc_playlist_get_input( libvlc_instance_t *p_instance,
151 libvlc_exception_t *p_e )
153 libvlc_input_t *p_input;
156 vlc_mutex_lock( &PL->object_lock );
157 if( PL->p_input == NULL )
159 libvlc_exception_raise( p_e, "No active input" );
160 vlc_mutex_unlock( &PL->object_lock );
163 p_input = (libvlc_input_t *)malloc( sizeof( libvlc_input_t ) );
165 p_input->i_input_id = PL->p_input->i_object_id;
166 p_input->p_instance = p_instance;
167 vlc_mutex_unlock( &PL->object_lock );