Commit 4ce74b60 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Use lambda functions to handle events

parent 0199c315
This diff is collapsed.
......@@ -302,12 +302,12 @@ public:
*
* \return event manager object
*/
EventManagerPtr eventManager()
MediaEventManagerPtr eventManager()
{
if ( m_eventManager == NULL )
{
libvlc_event_manager_t* obj = libvlc_media_event_manager(*this);
m_eventManager = std::make_shared<EventManager>( obj );
m_eventManager = std::make_shared<MediaEventManager>( obj );
}
return m_eventManager;
}
......@@ -438,7 +438,7 @@ private:
private:
EventManagerPtr m_eventManager;
MediaEventManagerPtr m_eventManager;
};
} // namespace VLC
......
......@@ -71,12 +71,12 @@ public:
*
* \return event manager object.
*/
EventManagerPtr eventManager()
MediaDiscovererEventManagerPtr eventManager()
{
if ( m_eventManager )
{
libvlc_event_manager_t* obj = libvlc_media_discoverer_event_manager( *this );
m_eventManager = std::make_shared<EventManager>( obj );
m_eventManager = std::make_shared<MediaDiscovererEventManager>( obj );
}
return m_eventManager;
}
......@@ -92,7 +92,7 @@ public:
}
private:
EventManagerPtr m_eventManager;
MediaDiscovererEventManagerPtr m_eventManager;
};
} // namespace VLC
......
......@@ -225,18 +225,18 @@ public:
*
* \return libvlc_event_manager
*/
EventManagerPtr eventManager()
MediaListEventManagerPtr eventManager()
{
if ( m_eventManager )
{
libvlc_event_manager_t* obj = libvlc_media_list_event_manager( *this );
m_eventManager = std::make_shared<EventManager>( obj );
m_eventManager = std::make_shared<MediaListEventManager>( obj );
}
return m_eventManager;
}
private:
EventManagerPtr m_eventManager;
MediaListEventManagerPtr m_eventManager;
};
} // namespace VLC
......
......@@ -31,7 +31,7 @@
namespace VLC
{
class EventManager;
class MediaListEventManager;
class MediaPlayer;
class MediaList;
......@@ -65,12 +65,12 @@ public:
*
* \return the event manager
*/
EventManagerPtr eventManager()
MediaListPlayerEventManagerPtr eventManager()
{
if ( m_eventManager )
{
libvlc_event_manager_t* obj = libvlc_media_list_player_event_manager(*this);
m_eventManager = std::make_shared<EventManager>( obj );
m_eventManager = std::make_shared<MediaListPlayerEventManager>( obj );
}
return m_eventManager;
}
......@@ -198,7 +198,7 @@ public:
}
private:
EventManagerPtr m_eventManager;
MediaListPlayerEventManagerPtr m_eventManager;
};
......
......@@ -32,11 +32,11 @@
namespace VLC
{
class EventManager;
class AudioOutputDeviceDescription;
class TrackDescription;
class Instance;
class Media;
class MediaPlayerEventManager;
class MediaPlayer : public Internal<libvlc_media_player_t>
{
......@@ -105,12 +105,12 @@ public:
*
* \return the event manager associated with p_mi
*/
EventManagerPtr eventManager()
MediaPlayerEventManagerPtr eventManager()
{
if ( m_eventManager == NULL )
{
libvlc_event_manager_t* obj = libvlc_media_player_event_manager( *this );
m_eventManager = std::make_shared<EventManager>( obj );
m_eventManager = std::make_shared<MediaPlayerEventManager>( obj );
}
return m_eventManager;
}
......@@ -1575,7 +1575,7 @@ private:
}
private:
EventManagerPtr m_eventManager;
MediaPlayerEventManagerPtr m_eventManager;
};
......
......@@ -32,6 +32,21 @@ namespace VLC
class EventManager;
using EventManagerPtr = std::shared_ptr<EventManager>;
class MediaEventManager;
using MediaEventManagerPtr = std::shared_ptr<MediaEventManager>;
class MediaPlayerEventManager;
using MediaPlayerEventManagerPtr = std::shared_ptr<MediaPlayerEventManager>;
class MediaListPlayerEventManager;
using MediaListPlayerEventManagerPtr = std::shared_ptr<MediaListPlayerEventManager>;
class MediaDiscovererEventManager;
using MediaDiscovererEventManagerPtr = std::shared_ptr<MediaDiscovererEventManager>;
class MediaListEventManager;
using MediaListEventManagerPtr = std::shared_ptr<MediaListEventManager>;
class Media;
using MediaPtr = std::shared_ptr<Media>;
......
......@@ -13,6 +13,10 @@ int main(int ac, char** av)
auto instance = VLC::Instance(0, nullptr);
auto media = VLC::Media(instance, av[1], VLC::Media::FromPath);
auto mp = VLC::MediaPlayer(media);
auto eventManager = mp.eventManager();
eventManager->onPlaying([&media]() {
std::cout << media.mrl() << " is playing" << std::endl;
});
mp.play();
std::this_thread::sleep_for( std::chrono::seconds( 20 ) );
......
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