Commit 5871680a authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

media_player: Emit an event when the root media is changed.

parent 43db2ff1
...@@ -101,7 +101,9 @@ extern "C" { ...@@ -101,7 +101,9 @@ extern "C" {
DEF( VlmMediaInstanceStatusPause ), \ DEF( VlmMediaInstanceStatusPause ), \
DEF( VlmMediaInstanceStatusEnd ), \ DEF( VlmMediaInstanceStatusEnd ), \
DEF( VlmMediaInstanceStatusError ), \ DEF( VlmMediaInstanceStatusError ), \
/* New event types HERE */ \
DEF( MediaPlayerMediaChanged ), \
/* New event types HERE */
#ifdef __cplusplus #ifdef __cplusplus
enum libvlc_event_type_e { enum libvlc_event_type_e {
...@@ -248,6 +250,12 @@ struct libvlc_event_t ...@@ -248,6 +250,12 @@ struct libvlc_event_t
const char * psz_media_name; const char * psz_media_name;
const char * psz_instance_name; const char * psz_instance_name;
} vlm_media_event; } vlm_media_event;
/* Extra MediaPlayer */
struct
{
libvlc_media_t * new_media;
} media_player_media_changed;
} u; } u;
}; };
......
...@@ -393,6 +393,8 @@ libvlc_media_player_new( libvlc_instance_t *instance, libvlc_exception_t *e ) ...@@ -393,6 +393,8 @@ libvlc_media_player_new( libvlc_instance_t *instance, libvlc_exception_t *e )
/* Snapshot initialization */ /* Snapshot initialization */
register_event(mp, SnapshotTaken); register_event(mp, SnapshotTaken);
register_event(mp, MediaChanged);
/* Attach a var callback to the global object to provide the glue between /* Attach a var callback to the global object to provide the glue between
* vout_thread that generates the event and media_player that re-emits it * vout_thread that generates the event and media_player that re-emits it
* with its own event manager * with its own event manager
...@@ -533,6 +535,13 @@ void libvlc_media_player_set_media( ...@@ -533,6 +535,13 @@ void libvlc_media_player_set_media(
p_mi->p_libvlc_instance = p_md->p_libvlc_instance; p_mi->p_libvlc_instance = p_md->p_libvlc_instance;
unlock(p_mi); unlock(p_mi);
/* Send an event for the newly available media */
libvlc_event_t event;
event.type = libvlc_MediaPlayerMediaChanged;
event.u.media_player_media_changed.new_media = p_md;
libvlc_event_send( p_mi->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