[vlc-commits] libvlc: add the title in title_selection_changed event

Thomas Guillem git at videolan.org
Mon May 4 10:08:53 CEST 2020


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Apr 28 13:18:39 2020 +0200| [1a54fc564187b3edf08548ff1452d4c2b5e6dfcc] | committer: Thomas Guillem

libvlc: add the title in title_selection_changed event

Because calling libvlc_media_player_get_full_title_descriptions(), getting the
title via the index and releasing the whole list is not convenient to get the
info about the selected title.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1a54fc564187b3edf08548ff1452d4c2b5e6dfcc
---

 include/vlc/libvlc_events.h | 8 +++++++-
 lib/media_player.c          | 9 ++++++++-
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/include/vlc/libvlc_events.h b/include/vlc/libvlc_events.h
index 0580888c4f..f1a5974d15 100644
--- a/include/vlc/libvlc_events.h
+++ b/include/vlc/libvlc_events.h
@@ -34,6 +34,7 @@ extern "C" {
 # endif
 
 typedef struct libvlc_renderer_item_t libvlc_renderer_item_t;
+typedef struct libvlc_title_description_t libvlc_title_description_t;
 
 /**
  * \ingroup libvlc_event
@@ -118,6 +119,10 @@ enum libvlc_event_e {
     libvlc_MediaPlayerUnmuted,
     libvlc_MediaPlayerAudioVolume,
     libvlc_MediaPlayerAudioDevice,
+    /**
+     * The title selection changed, cf media_player_title_selection_changed in
+     * \ref libvlc_event_t.u
+     */
     libvlc_MediaPlayerTitleSelectionChanged,
     libvlc_MediaPlayerChapterChanged,
 
@@ -266,7 +271,8 @@ typedef struct libvlc_event_t
         } media_player_time_changed;
         struct
         {
-            int new_title;
+            const libvlc_title_description_t *title;
+            int index;
         } media_player_title_selection_changed;
         struct
         {
diff --git a/lib/media_player.c b/lib/media_player.c
index 42d20537c6..271c244740 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -342,9 +342,16 @@ on_title_selection_changed(vlc_player_t *player,
 
     libvlc_media_player_t *mp = data;
 
+    const libvlc_title_description_t libtitle = {
+        .i_duration = MS_FROM_VLC_TICK(new_title->length),
+        .psz_name = (char *) new_title->name,
+        .i_flags = new_title->flags,
+    };
+
     libvlc_event_t event;
     event.type = libvlc_MediaPlayerTitleSelectionChanged;
-    event.u.media_player_title_selection_changed.new_title = new_idx;
+    event.u.media_player_title_selection_changed.title = &libtitle;
+    event.u.media_player_title_selection_changed.index = new_idx;
 
     libvlc_event_send(&mp->event_manager, &event);
 }



More information about the vlc-commits mailing list