[vlc-commits] ActiveX: add events

Jean-Baptiste Kempf git at videolan.org
Mon Dec 15 21:56:31 CET 2014


npapi-vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Mon Dec 15 21:55:30 2014 +0100| [8af862b12c24e192c08ec9bb029740deb56e2928] | committer: Jean-Baptiste Kempf

ActiveX: add events

- MediaPlayerMediaChanged
- MediaPlayerTitleChanged
- MediaPlayerLengthChanged

Ref #11486

> http://git.videolan.org/gitweb.cgi/npapi-vlc.git/?a=commit;h=8af862b12c24e192c08ec9bb029740deb56e2928
---

 activex/axvlc.idl  |    9 +++++++++
 activex/plugin.cpp |   53 +++++++++++++++++++++++++++++++++++++++++++++++++---
 activex/plugin.h   |    3 +++
 3 files changed, 62 insertions(+), 3 deletions(-)

diff --git a/activex/axvlc.idl b/activex/axvlc.idl
index 145e9ae..3d557cd 100644
--- a/activex/axvlc.idl
+++ b/activex/axvlc.idl
@@ -185,6 +185,9 @@ library AXVLC
     const int DISPID_MediaPlayerPositionChangedEvent = 211;
     const int DISPID_MediaPlayerSeekableChangedEvent = 212;
     const int DISPID_MediaPlayerPausableChangedEvent = 213;
+    const int DISPID_MediaPlayerMediaChangedEvent = 214;
+    const int DISPID_MediaPlayerTitleChangedEvent = 215;
+    const int DISPID_MediaPlayerLengthChangedEvent = 216;
 
     [
       uuid(DF48072F-5EF8-434e-9B40-E2F3AE759B5F),
@@ -231,6 +234,12 @@ library AXVLC
             void MediaPlayerSeekableChanged([in] VARIANT_BOOL seekable);
             [id(DISPID_MediaPlayerPausableChangedEvent), helpstring("Pause setting changed")]
             void MediaPlayerPausableChanged([in] VARIANT_BOOL pausable);
+            [id(DISPID_MediaPlayerMediaChangedEvent), helpstring("Media changed")]
+            void MediaPlayerMediaChanged();
+            [id(DISPID_MediaPlayerTitleChangedEvent), helpstring("Title changed")]
+            void MediaPlayerTitleChanged([in] int title);
+            [id(DISPID_MediaPlayerLengthChangedEvent), helpstring("Length changed")]
+            void MediaPlayerLengthChanged([in] long length);
     };
 
     [
diff --git a/activex/plugin.cpp b/activex/plugin.cpp
index 07acfb4..83c5ad2 100644
--- a/activex/plugin.cpp
+++ b/activex/plugin.cpp
@@ -1009,6 +1009,12 @@ void VLCPlugin::fireOnStopEvent(void)
 /*
  * Async events
  */
+void VLCPlugin::fireOnMediaPlayerMediaChangedEvent()
+{
+    DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
+    vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerMediaChangedEvent, &dispparamsNoArgs);
+};
+
 void VLCPlugin::fireOnMediaPlayerNothingSpecialEvent()
 {
     DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
@@ -1081,6 +1087,9 @@ static void handle_input_state_event(const libvlc_event_t* event, void *param)
     VLCPlugin *plugin = (VLCPlugin*)param;
     switch( event->type )
     {
+        case libvlc_MediaPlayerMediaChanged:
+            plugin->fireOnMediaPlayerMediaChangedEvent();
+            break;        
         case libvlc_MediaPlayerNothingSpecial:
             plugin->fireOnMediaPlayerNothingSpecialEvent();
             break;
@@ -1192,6 +1201,44 @@ static void handle_pausable_changed_event(const libvlc_event_t* event, void *par
 }
 #undef B
 
+void VLCPlugin::fireOnMediaPlayerTitleChangedEvent(int title)
+{
+    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 = title;
+    params.rgdispidNamedArgs = NULL;
+    params.cNamedArgs = 0;
+    vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerTitleChangedEvent, &params);
+};
+
+static void handle_title_changed_event(const libvlc_event_t* event, void *param)
+{
+    VLCPlugin *plugin = (VLCPlugin*)param;
+    plugin->fireOnMediaPlayerTitleChangedEvent(event->u.media_player_title_changed.new_title);
+}
+
+void VLCPlugin::fireOnMediaPlayerLengthChangedEvent(long length)
+{
+    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_I4;
+    params.rgvarg[0].lVal = length;
+    params.rgdispidNamedArgs = NULL;
+    params.cNamedArgs = 0;
+    vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerLengthChangedEvent, &params);
+};
+
+static void handle_length_changed_event(const libvlc_event_t* event, void *param)
+{
+    VLCPlugin *plugin = (VLCPlugin*)param;
+    plugin->fireOnMediaPlayerLengthChangedEvent(event->u.media_player_length_changed.new_length);
+}
+
 /* */
 
 void VLCPlugin::set_player_window()
@@ -1218,7 +1265,7 @@ void VLCPlugin::on_player_action(vlc_player_action_e pa)
 }
 
 static vlcplugin_event_t vlcevents[] = {
-    //{ libvlc_MediaPlayerMediaChanged, handle_input_state_event },         // unused
+    { libvlc_MediaPlayerMediaChanged, handle_input_state_event },
     { libvlc_MediaPlayerNothingSpecial, handle_input_state_event },
     { libvlc_MediaPlayerOpening, handle_input_state_event },
     { libvlc_MediaPlayerBuffering, handle_input_state_event },
@@ -1233,8 +1280,8 @@ static vlcplugin_event_t vlcevents[] = {
     { libvlc_MediaPlayerPositionChanged, handle_position_changed_event },
     { libvlc_MediaPlayerSeekableChanged, handle_seekable_changed_event },
     { libvlc_MediaPlayerPausableChanged, handle_pausable_changed_event },
-    //{ libvlc_MediaPlayerTitleChanged, handle_input_state_event },         // unused
-    //{ libvlc_MediaPlayerLengthChanged, handle_input_state_event },        // unused
+    { libvlc_MediaPlayerTitleChanged, handle_title_changed_event },
+    { libvlc_MediaPlayerLengthChanged, handle_length_changed_event },
 };
 
 void VLCPlugin::player_register_events()
diff --git a/activex/plugin.h b/activex/plugin.h
index dbd7f2f..5d34b3f 100644
--- a/activex/plugin.h
+++ b/activex/plugin.h
@@ -280,6 +280,9 @@ public:
     void fireOnMediaPlayerPositionChangedEvent(float position);
     void fireOnMediaPlayerSeekableChangedEvent(VARIANT_BOOL seekable);
     void fireOnMediaPlayerPausableChangedEvent(VARIANT_BOOL pausable);
+    void fireOnMediaPlayerMediaChangedEvent();
+    void fireOnMediaPlayerTitleChangedEvent(int title);
+    void fireOnMediaPlayerLengthChangedEvent(long length);
 
     // controlling IUnknown interface
     LPUNKNOWN pUnkOuter;



More information about the vlc-commits mailing list