/* * Known issues: since moving in the playlist using playlist_Next * or playlist_Prev implies starting to play items, the a_position * argument will be only honored for the 1st item in the list. * * XXX:FIXME split moving in the playlist and playing items two * different actions or make playlist_<Next|Prev> accept a time * value to start to play from. */ void mediacontrol_start( mediacontrol_Instance *self, const mediacontrol_Position * a_position, mediacontrol_Exception *exception ) { playlist_t * p_playlist = self->p_playlist; exception = mediacontrol_exception_init( exception ); if( ! p_playlist ) { RAISE( mediacontrol_PlaylistException, "No available playlist" ); return; } vlc_mutex_lock( &p_playlist->object_lock ); if( p_playlist->i_size ) { int i_index; int i_from; char *psz_from = NULL; psz_from = ( char * )malloc( 20 * sizeof( char ) ); if( psz_from ) { i_from = mediacontrol_position2microsecond( p_playlist->p_input, a_position ) / 1000000; i_index = p_playlist->i_index; if( i_index < 0 ) { /* We know that there is at least 1 element, since i_size != 0 */ i_index = 0; } /* Set start time */ snprintf( psz_from, 20, "start-time=%i", i_from ); playlist_ItemAddOption( p_playlist->pp_items[i_index], psz_from ); free( psz_from ); } vlc_mutex_unlock( &p_playlist->object_lock ); playlist_Play( p_playlist ); } else { RAISE( mediacontrol_PlaylistException, "Empty playlist." ); vlc_mutex_unlock( &p_playlist->object_lock ); } }
/***************************************************************************** * Demux: The important stuff *****************************************************************************/ static int Demux( demux_t *p_demux ) { playlist_t *p_playlist; char *psz_line; playlist_item_t *p_current; vlc_bool_t b_play; p_playlist = (playlist_t *) vlc_object_find( p_demux, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( !p_playlist ) { msg_Err( p_demux, "can't find playlist" ); return -1; } b_play = E_(FindItem)( p_demux, p_playlist, &p_current ); playlist_ItemToNode( p_playlist, p_current ); p_current->input.i_type = ITEM_TYPE_PLAYLIST; while( (psz_line = stream_ReadLine( p_demux->s )) ) { playlist_item_t *p_item; char **ppsz_options = NULL; int i, i_options = 0; char *psz_name = NULL; if( !ParseLine( psz_line, &psz_name, &ppsz_options, &i_options ) ) { free( psz_line ); continue; } EnsureUTF8( psz_name ); p_item = playlist_ItemNew( p_playlist, "dvb:", psz_name ); for( i = 0; i< i_options; i++ ) { EnsureUTF8( ppsz_options[i] ); playlist_ItemAddOption( p_item, ppsz_options[i] ); } playlist_NodeAddItem( p_playlist, p_item, p_current->pp_parents[0]->i_view, p_current, PLAYLIST_APPEND, PLAYLIST_END ); /* We need to declare the parents of the node as the * * same of the parent's ones */ playlist_CopyParents( p_current, p_item ); vlc_input_item_CopyOptions( &p_current->input, &p_item->input ); while( i_options-- ) free( ppsz_options[i_options] ); if( ppsz_options ) free( ppsz_options ); free( psz_line ); } /* Go back and play the playlist */ if( b_play && p_playlist->status.p_item && p_playlist->status.p_item->i_children > 0 ) { playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, p_playlist->status.i_view, p_playlist->status.p_item, p_playlist->status.p_item->pp_children[0] ); } vlc_object_release( p_playlist ); return VLC_SUCCESS; }