[vlc-commits] [Git][videolan/libvlcpp][master] 2 commits: structures: Fix TitleDescription constructor

Hugo Beauzée-Luyssen gitlab at videolan.org
Tue May 5 10:00:12 CEST 2020



Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / libvlcpp


Commits:
c20067af by Hugo Beauzée-Luyssen at 2020-05-05T09:56:24+02:00
structures: Fix TitleDescription constructor

It only needs a const libvlc_title_description_t*.

- - - - -
a490f041 by Hugo Beauzée-Luyssen at 2020-05-05T09:57:53+02:00
EventManager: Wrap new title events

- - - - -


3 changed files:

- test/main.cpp
- vlcpp/EventManager.hpp
- vlcpp/structures.hpp


Changes:

=====================================
test/main.cpp
=====================================
@@ -105,6 +105,10 @@ int main(int ac, char** av)
     auto lFunc = std::function<void(float)>{ l };
     auto h1 = mp.eventManager().onTimeChanged(lFunc);
     auto h2 = mp.eventManager().onPositionChanged(lFunc);
+    mp.eventManager().onTitleSelectionChanged(
+                [](const VLC::TitleDescription& t, int idx ) {
+        std::cout << "New title selected: " << t.name() << " at index " << idx << std::endl;
+    });
 
     std::this_thread::sleep_for( std::chrono::seconds( 2 ) );
 


=====================================
vlcpp/EventManager.hpp
=====================================
@@ -612,6 +612,35 @@ class MediaPlayerEventManager : public EventManager
             });
         }
 
+#if LIBVLC_VERSION_INT >= LIBVLC_VERSION(4, 0, 0, 0)
+        /**
+         * \brief onTitleListChanged Registers an event called when the list of titles changes
+         * \param f A std::function<void(void)> (or an equivalent Callable type)
+         *
+         * The updated list can be obtained by calling MediaPlayer::titleDescription()
+         */
+        template <typename Func>
+        RegisteredEvent onTitleListChanged( Func&& f )
+        {
+            return handle( libvlc_MediaPlayerTitleListChanged, std::forward<Func>( f ) );
+        }
+
+        /**
+         * \brief onTitleSelectionChanged Registers an event called when the title selection changes
+         * \param f A std::function<void(const TitleDescription&, int)> (or an equivalent callable type)
+         */
+        template <typename Func>
+        RegisteredEvent onTitleSelectionChanged( Func&& f )
+        {
+            EXPECT_SIGNATURE(void(const TitleDescription&, int));
+            return handle( libvlc_MediaPlayerTitleSelectionChanged, std::forward<Func>( f ), [](const libvlc_event_t* e, void* data)
+            {
+                auto callback = static_cast<DecayPtr<Func>>( data );
+                (*callback)( TitleDescription{ e->u.media_player_title_selection_changed.title },
+                             e->u.media_player_title_selection_changed.index );
+            });
+        }
+#else
         /**
          * \brief onTitleChanged Registers an event called when the current title changes
          * \param f A std::function<void(int)> (or an equivalent Callable type)
@@ -629,6 +658,7 @@ class MediaPlayerEventManager : public EventManager
                 (*callback)( e->u.media_player_title_changed.new_title );
             });
         }
+#endif
 
 #if LIBVLC_VERSION_INT >= LIBVLC_VERSION(3, 0, 0, 0)
         /**


=====================================
vlcpp/structures.hpp
=====================================
@@ -562,7 +562,7 @@ public:
         return ( m_flags & libvlc_title_interactive ) != 0;
     }
 
-    explicit TitleDescription( libvlc_title_description_t* c )
+    explicit TitleDescription( const libvlc_title_description_t* c )
         : m_duration( c->i_duration ), m_flags( c->i_flags )
     {
         if ( c->psz_name != nullptr )



View it on GitLab: https://code.videolan.org/videolan/libvlcpp/-/compare/e81b9f06493becabeec794e351bb357a90af264a...a490f04156224277e28a3a4131125a32b798e84d

-- 
View it on GitLab: https://code.videolan.org/videolan/libvlcpp/-/compare/e81b9f06493becabeec794e351bb357a90af264a...a490f04156224277e28a3a4131125a32b798e84d
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list