Commit af6aa60c authored by Daniel Amm's avatar Daniel Amm Committed by Hugo Beauzée-Luyssen

Add some useful events to the JS API

Signed-off-by: default avatarHugo Beauzée-Luyssen <hugo@beauzee.fr>
parent 70f104eb
...@@ -84,6 +84,12 @@ library AXVLC ...@@ -84,6 +84,12 @@ library AXVLC
const int DISPID_MediaPlayerMediaChangedEvent = 214; const int DISPID_MediaPlayerMediaChangedEvent = 214;
const int DISPID_MediaPlayerTitleChangedEvent = 215; const int DISPID_MediaPlayerTitleChangedEvent = 215;
const int DISPID_MediaPlayerLengthChangedEvent = 216; const int DISPID_MediaPlayerLengthChangedEvent = 216;
const int DISPID_MediaPlayerChapterChangedEvent = 217;
const int DISPID_MediaPlayerVoutEvent = 218;
const int DISPID_MediaPlayerMutedEvent = 219;
const int DISPID_MediaPlayerUnmutedEvent = 220;
const int DISPID_MediaPlayerAudioVolumeEvent = 221;
[ [
uuid(DF48072F-5EF8-434e-9B40-E2F3AE759B5F), uuid(DF48072F-5EF8-434e-9B40-E2F3AE759B5F),
...@@ -129,6 +135,17 @@ library AXVLC ...@@ -129,6 +135,17 @@ library AXVLC
void MediaPlayerTitleChanged([in] int title); void MediaPlayerTitleChanged([in] int title);
[id(DISPID_MediaPlayerLengthChangedEvent), helpstring("Length changed")] [id(DISPID_MediaPlayerLengthChangedEvent), helpstring("Length changed")]
void MediaPlayerLengthChanged([in] long length); void MediaPlayerLengthChanged([in] long length);
[id(DISPID_MediaPlayerChapterChangedEvent), helpstring("Chapter changed")]
void MediaPlayerChapterChanged([in] int chapter);
[id(DISPID_MediaPlayerVoutEvent), helpstring("Number of vout changed")]
void MediaPlayerVout([in] int count);
[id(DISPID_MediaPlayerMutedEvent), helpstring("Audio muted")]
void MediaPlayerMuted();
[id(DISPID_MediaPlayerUnmutedEvent), helpstring("Audio unmuted")]
void MediaPlayerUnmuted();
[id(DISPID_MediaPlayerAudioVolumeEvent), helpstring("Audio volume changed")]
void MediaPlayerAudioVolume([in] float volume);
}; };
[ [
......
...@@ -1114,6 +1114,61 @@ void VLCPlugin::fireOnMediaPlayerLengthChangedEvent(long length) ...@@ -1114,6 +1114,61 @@ void VLCPlugin::fireOnMediaPlayerLengthChangedEvent(long length)
vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerLengthChangedEvent, &params); vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerLengthChangedEvent, &params);
} }
#if LIBVLC_VERSION_INT >= LIBVLC_VERSION(3, 0, 0, 0)
void VLCPlugin::fireOnMediaPlayerChapterChangedEvent(int chapter)
{
DISPPARAMS params;
params.cArgs = 1;
params.rgvarg = (VARIANTARG *) CoTaskMemAlloc(sizeof(VARIANTARG) * params.cArgs) ;
memset(params.rgvarg, 0, sizeof(VARIANTARG) * params.cArgs);
params.rgvarg[0].vt = VT_I2;
params.rgvarg[0].iVal = chapter;
params.rgdispidNamedArgs = NULL;
params.cNamedArgs = 0;
vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerChapterChangedEvent, &params);
}
#endif
void VLCPlugin::fireOnMediaPlayerVoutEvent(int count)
{
DISPPARAMS params;
params.cArgs = 1;
params.rgvarg = (VARIANTARG *) CoTaskMemAlloc(sizeof(VARIANTARG) * params.cArgs) ;
memset(params.rgvarg, 0, sizeof(VARIANTARG) * params.cArgs);
params.rgvarg[0].vt = VT_I2;
params.rgvarg[0].iVal = count;
params.rgdispidNamedArgs = NULL;
params.cNamedArgs = 0;
vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerVoutEvent, &params);
}
#if LIBVLC_VERSION_INT >= LIBVLC_VERSION(2, 2, 2, 0)
void VLCPlugin::fireOnMediaPlayerMutedEvent()
{
DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerMutedEvent, &dispparamsNoArgs);
}
void VLCPlugin::fireOnMediaPlayerUnmutedEvent()
{
DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerUnmutedEvent, &dispparamsNoArgs);
}
void VLCPlugin::fireOnMediaPlayerAudioVolumeEvent(float volume)
{
DISPPARAMS params;
params.cArgs = 1;
params.rgvarg = (VARIANTARG *) CoTaskMemAlloc(sizeof(VARIANTARG) * params.cArgs) ;
memset(params.rgvarg, 0, sizeof(VARIANTARG) * params.cArgs);
params.rgvarg[0].vt = VT_R4;
params.rgvarg[0].fltVal = volume;
params.rgdispidNamedArgs = NULL;
params.cNamedArgs = 0;
vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerAudioVolumeEvent, &params);
}
#endif
/* */ /* */
void VLCPlugin::set_player_window() void VLCPlugin::set_player_window()
...@@ -1178,6 +1233,25 @@ void VLCPlugin::player_register_events() ...@@ -1178,6 +1233,25 @@ void VLCPlugin::player_register_events()
em.onLengthChanged( [this]( int64_t length ) { em.onLengthChanged( [this]( int64_t length ) {
fireOnMediaPlayerLengthChangedEvent( length ); fireOnMediaPlayerLengthChangedEvent( length );
}); });
#if LIBVLC_VERSION_INT >= LIBVLC_VERSION(3, 0, 0, 0)
em.onChapterChanged( [this]( int chapter ) {
fireOnMediaPlayerChapterChangedEvent( chapter );
});
#endif
em.onVout( [this]( int count ) {
fireOnMediaPlayerVoutEvent( count );
});
#if LIBVLC_VERSION_INT >= LIBVLC_VERSION(2, 2, 2, 0)
em.onMuted( [this] {
fireOnMediaPlayerMutedEvent();
});
em.onUnmuted( [this] {
fireOnMediaPlayerUnmutedEvent();
});
em.onAudioVolume( [this]( float volume ) {
fireOnMediaPlayerAudioVolumeEvent( volume );
});
#endif
} }
#undef B #undef B
...@@ -258,6 +258,16 @@ public: ...@@ -258,6 +258,16 @@ public:
void fireOnMediaPlayerMediaChangedEvent(); void fireOnMediaPlayerMediaChangedEvent();
void fireOnMediaPlayerTitleChangedEvent(int title); void fireOnMediaPlayerTitleChangedEvent(int title);
void fireOnMediaPlayerLengthChangedEvent(long length); void fireOnMediaPlayerLengthChangedEvent(long length);
#if LIBVLC_VERSION_INT >= LIBVLC_VERSION(3, 0, 0, 0)
void fireOnMediaPlayerChapterChangedEvent(int chapter);
#endif
void fireOnMediaPlayerVoutEvent(int count);
#if LIBVLC_VERSION_INT >= LIBVLC_VERSION(2, 2, 2, 0)
void fireOnMediaPlayerMutedEvent();
void fireOnMediaPlayerUnmutedEvent();
void fireOnMediaPlayerAudioVolumeEvent(float volume);
#endif
// controlling IUnknown interface // controlling IUnknown interface
LPUNKNOWN pUnkOuter; LPUNKNOWN pUnkOuter;
......
...@@ -373,7 +373,16 @@ static struct vlcevents_t { ...@@ -373,7 +373,16 @@ static struct vlcevents_t {
{ "MediaPlayerSeekableChanged", libvlc_MediaPlayerSeekableChanged }, { "MediaPlayerSeekableChanged", libvlc_MediaPlayerSeekableChanged },
{ "MediaPlayerPausableChanged", libvlc_MediaPlayerPausableChanged }, { "MediaPlayerPausableChanged", libvlc_MediaPlayerPausableChanged },
{ "MediaPlayerTitleChanged", libvlc_MediaPlayerTitleChanged }, { "MediaPlayerTitleChanged", libvlc_MediaPlayerTitleChanged },
#if LIBVLC_VERSION_INT >= LIBVLC_VERSION(3, 0, 0, 0)
{ "MediaPlayerChapterChanged", libvlc_MediaPlayerChapterChanged },
#endif
{ "MediaPlayerLengthChanged", libvlc_MediaPlayerLengthChanged }, { "MediaPlayerLengthChanged", libvlc_MediaPlayerLengthChanged },
{ "MediaPlayerVout", libvlc_MediaPlayerVout },
#if LIBVLC_VERSION_INT >= LIBVLC_VERSION(2, 2, 2, 0)
{ "MediaPlayerMuted", libvlc_MediaPlayerMuted },
{ "MediaPlayerUnmuted", libvlc_MediaPlayerUnmuted },
{ "MediaPlayerAudioVolume", libvlc_MediaPlayerAudioVolume },
#endif
}; };
void VlcPluginBase::subscribe(const char* eventName, npapi::Variant listener) void VlcPluginBase::subscribe(const char* eventName, npapi::Variant listener)
...@@ -438,9 +447,28 @@ void VlcPluginBase::subscribe(const char* eventName, npapi::Variant listener) ...@@ -438,9 +447,28 @@ void VlcPluginBase::subscribe(const char* eventName, npapi::Variant listener)
case libvlc_MediaPlayerTitleChanged: case libvlc_MediaPlayerTitleChanged:
e = player().get_mp().eventManager().onTitleChanged( std::move( closure ) ); e = player().get_mp().eventManager().onTitleChanged( std::move( closure ) );
break; break;
#if LIBVLC_VERSION_INT >= LIBVLC_VERSION(3, 0, 0, 0)
case libvlc_MediaPlayerChapterChanged:
e = player().get_mp().eventManager().onChapterChanged( std::move( closure ) );
break;
#endif
case libvlc_MediaPlayerLengthChanged: case libvlc_MediaPlayerLengthChanged:
e = player().get_mp().eventManager().onLengthChanged( std::move( closure ) ); e = player().get_mp().eventManager().onLengthChanged( std::move( closure ) );
break; break;
case libvlc_MediaPlayerVout:
e = player().get_mp().eventManager().onVout( std::move( closure ) );
break;
#if LIBVLC_VERSION_INT >= LIBVLC_VERSION(2, 2, 2, 0)
case libvlc_MediaPlayerMuted:
e = player().get_mp().eventManager().onMuted( std::move( closure ) );
break;
case libvlc_MediaPlayerUnmuted:
e = player().get_mp().eventManager().onUnmuted( std::move( closure ) );
break;
case libvlc_MediaPlayerAudioVolume:
e = player().get_mp().eventManager().onAudioVolume( std::move( closure ) );
break;
#endif
default: default:
break; break;
} }
......
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