Commit 6984b615 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

src/control: Various events addition.

parent 49eb715c
...@@ -301,12 +301,19 @@ typedef enum libvlc_event_type_t { ...@@ -301,12 +301,19 @@ typedef enum libvlc_event_type_t {
libvlc_MediaDescriptorMetaChanged, libvlc_MediaDescriptorMetaChanged,
libvlc_MediaDescriptorSubItemAdded, libvlc_MediaDescriptorSubItemAdded,
libvlc_MediaInstancePlayed,
libvlc_MediaInstancePaused,
libvlc_MediaInstanceReachedEnd, libvlc_MediaInstanceReachedEnd,
libvlc_MediaInstancePositionChanged,
libvlc_MediaListItemAdded, libvlc_MediaListItemAdded,
libvlc_MediaListItemDeleted, libvlc_MediaListItemDeleted,
libvlc_MediaListItemChanged, libvlc_MediaListItemChanged,
libvlc_MediaListPlayerPlayed,
libvlc_MediaListPlayerNextItemSet,
libvlc_MediaListPlayerStopped,
libvlc_TreeSubtreeAdded, libvlc_TreeSubtreeAdded,
libvlc_TreeSubtreeDeleted, libvlc_TreeSubtreeDeleted,
libvlc_TreeItemValueChanged, libvlc_TreeItemValueChanged,
...@@ -336,6 +343,12 @@ typedef struct libvlc_event_t ...@@ -336,6 +343,12 @@ typedef struct libvlc_event_t
libvlc_media_descriptor_t * new_child; libvlc_media_descriptor_t * new_child;
} media_descriptor_subitem_added; } media_descriptor_subitem_added;
/* media instance */
struct
{
uint64_t new_position;
} media_instance_position_changed;
/* media list */ /* media list */
struct struct
{ {
......
...@@ -125,6 +125,12 @@ input_state_changed( vlc_object_t * p_this, char const * psz_cmd, ...@@ -125,6 +125,12 @@ input_state_changed( vlc_object_t * p_this, char const * psz_cmd,
case END_S: case END_S:
event.type = libvlc_MediaInstanceReachedEnd; event.type = libvlc_MediaInstanceReachedEnd;
break; break;
case PAUSE_S:
event.type = libvlc_MediaInstancePaused;
break;
case PLAYING_S:
event.type = libvlc_MediaInstancePlayed;
break;
default: default:
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -133,6 +139,40 @@ input_state_changed( vlc_object_t * p_this, char const * psz_cmd, ...@@ -133,6 +139,40 @@ input_state_changed( vlc_object_t * p_this, char const * psz_cmd,
return VLC_SUCCESS; return VLC_SUCCESS;
} }
/*
* input_position_changed (Private) (input var "intf-change" Callback)
*/
static int
input_position_changed( vlc_object_t * p_this, char const * psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
void * p_userdata )
{
libvlc_media_instance_t * p_mi = p_userdata;
vlc_value_t val;
if (!strcmp(psz_cmd, "intf" /* "-change" no need to go further */))
{
input_thread_t * p_input = (input_thread_t *)p_this;
var_Get( p_input, "position", &val );
if ((val.i_time % I64C(500000)) != 0)
return VLC_SUCCESS; /* No need to have a better precision */
var_Get( p_input, "state", &val );
if( val.i_int != PLAYING_S )
return VLC_SUCCESS; /* Don't send the position while stopped */
}
else
val.i_time = newval.i_time;
libvlc_event_t event;
event.type = libvlc_MediaInstancePositionChanged;
event.u.media_instance_position_changed.new_position = val.i_time;
libvlc_event_send( p_mi->p_event_manager, &event );
return VLC_SUCCESS;
}
/************************************************************************** /**************************************************************************
* Create a Media Instance object * Create a Media Instance object
**************************************************************************/ **************************************************************************/
...@@ -419,6 +459,7 @@ void libvlc_media_instance_play( libvlc_media_instance_t *p_mi, ...@@ -419,6 +459,7 @@ void libvlc_media_instance_play( libvlc_media_instance_t *p_mi,
var_Set( p_input_thread, "drawable", val ); var_Set( p_input_thread, "drawable", val );
} }
var_AddCallback( p_input_thread, "state", input_state_changed, p_mi ); var_AddCallback( p_input_thread, "state", input_state_changed, p_mi );
var_AddCallback( p_input_thread, "intf-change", input_position_changed, p_mi );
/* will be released in media_instance_release() */ /* will be released in media_instance_release() */
vlc_object_yield( p_input_thread ); vlc_object_yield( p_input_thread );
......
...@@ -138,6 +138,7 @@ uninstall_media_instance_observer( libvlc_media_list_player_t * p_mlp ) ...@@ -138,6 +138,7 @@ uninstall_media_instance_observer( libvlc_media_list_player_t * p_mlp )
libvlc_MediaInstanceReachedEnd, libvlc_MediaInstanceReachedEnd,
media_instance_reached_end, p_mlp, NULL ); media_instance_reached_end, p_mlp, NULL );
} }
/************************************************************************** /**************************************************************************
* Stop (Public) * Stop (Public)
**************************************************************************/ **************************************************************************/
...@@ -191,7 +192,7 @@ media_list_player_set_next( libvlc_media_list_player_t * p_mlp, int index, ...@@ -191,7 +192,7 @@ media_list_player_set_next( libvlc_media_list_player_t * p_mlp, int index,
*/ */
/************************************************************************** /**************************************************************************
* libvlc_media_list_player_new (Public) * new (Public)
**************************************************************************/ **************************************************************************/
libvlc_media_list_player_t * libvlc_media_list_player_t *
libvlc_media_list_player_new( libvlc_instance_t * p_instance, libvlc_media_list_player_new( libvlc_instance_t * p_instance,
...@@ -204,12 +205,19 @@ libvlc_media_list_player_new( libvlc_instance_t * p_instance, ...@@ -204,12 +205,19 @@ libvlc_media_list_player_new( libvlc_instance_t * p_instance,
p_mlp->p_mi = NULL; p_mlp->p_mi = NULL;
p_mlp->p_mlist = NULL; p_mlp->p_mlist = NULL;
vlc_mutex_init( p_instance->p_libvlc_int, &p_mlp->object_lock ); vlc_mutex_init( p_instance->p_libvlc_int, &p_mlp->object_lock );
p_mlp->p_event_manager = libvlc_event_manager_new( p_mlp,
p_instance,
p_e );
libvlc_event_manager_register_event_type( p_mlp->p_event_manager,
libvlc_MediaListPlayerNextItemSet, p_e );
libvlc_event_manager_register_event_type( p_mlp->p_event_manager,
libvlc_MediaListPlayerNextItemSet, p_e );
return p_mlp; return p_mlp;
} }
/************************************************************************** /**************************************************************************
* libvlc_media_list_player_release (Public) * release (Public)
**************************************************************************/ **************************************************************************/
void libvlc_media_list_player_release( libvlc_media_list_player_t * p_mlp ) void libvlc_media_list_player_release( libvlc_media_list_player_t * p_mlp )
{ {
...@@ -217,7 +225,7 @@ void libvlc_media_list_player_release( libvlc_media_list_player_t * p_mlp ) ...@@ -217,7 +225,7 @@ void libvlc_media_list_player_release( libvlc_media_list_player_t * p_mlp )
} }
/************************************************************************** /**************************************************************************
* libvlc_media_list_player_set_media_instance (Public) * set_media_instance (Public)
**************************************************************************/ **************************************************************************/
void libvlc_media_list_player_set_media_instance( void libvlc_media_list_player_set_media_instance(
libvlc_media_list_player_t * p_mlp, libvlc_media_list_player_t * p_mlp,
...@@ -240,7 +248,7 @@ void libvlc_media_list_player_set_media_instance( ...@@ -240,7 +248,7 @@ void libvlc_media_list_player_set_media_instance(
} }
/************************************************************************** /**************************************************************************
* Set a playlist (Public) * set_media_list (Public)
**************************************************************************/ **************************************************************************/
void libvlc_media_list_player_set_media_list( void libvlc_media_list_player_set_media_list(
libvlc_media_list_player_t * p_mlp, libvlc_media_list_player_t * p_mlp,
...@@ -274,9 +282,7 @@ void libvlc_media_list_player_play( libvlc_media_list_player_t * p_mlp, ...@@ -274,9 +282,7 @@ void libvlc_media_list_player_play( libvlc_media_list_player_t * p_mlp,
if( p_mlp->i_current_playing_index < 0 ) if( p_mlp->i_current_playing_index < 0 )
{ {
libvlc_media_list_player_next( p_mlp, p_e ); libvlc_media_list_player_next( p_mlp, p_e );
return; /* Will set to play */
if( libvlc_exception_raised( p_e ) )
return;
} }
libvlc_media_instance_play( p_mlp->p_mi, p_e ); libvlc_media_instance_play( p_mlp->p_mi, p_e );
...@@ -297,6 +303,11 @@ void libvlc_media_list_player_play_item_at_index( ...@@ -297,6 +303,11 @@ void libvlc_media_list_player_play_item_at_index(
if( libvlc_exception_raised( p_e ) ) if( libvlc_exception_raised( p_e ) )
return; return;
/* Send the next item event */
libvlc_event_t event;
event.type = libvlc_MediaListPlayerNextItemSet;
libvlc_event_send( p_mlp->p_event_manager, &event );
libvlc_media_instance_play( p_mlp->p_mi, p_e ); libvlc_media_instance_play( p_mlp->p_mi, p_e );
} }
...@@ -336,6 +347,13 @@ void libvlc_media_list_player_next( libvlc_media_list_player_t * p_mlp, ...@@ -336,6 +347,13 @@ void libvlc_media_list_player_next( libvlc_media_list_player_t * p_mlp,
media_list_player_set_next( p_mlp, index, p_e ); media_list_player_set_next( p_mlp, index, p_e );
libvlc_media_instance_play( p_mlp->p_mi, p_e );
libvlc_media_list_unlock( p_mlp->p_mlist ); libvlc_media_list_unlock( p_mlp->p_mlist );
/* Send the next item event */
libvlc_event_t event;
event.type = libvlc_MediaListPlayerNextItemSet;
libvlc_event_send( p_mlp->p_event_manager, &event);
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment