From 9922b46c47219b10f5e33f966ed5d1dfd364c269 Mon Sep 17 00:00:00 2001 From: Jean-Paul Saman Date: Thu, 11 Feb 2010 15:01:52 +0100 Subject: [PATCH] activex: implement JS Events --- projects/activex/axvlc.idl | 65 +++++++ projects/activex/axvlc.tlb | Bin 20860 -> 22780 bytes projects/activex/axvlc_idl.c | 2 +- projects/activex/axvlc_idl.h | 38 +++- projects/activex/plugin.cpp | 351 ++++++++++++++++++++++++++++++++++- projects/activex/plugin.h | 26 +++ 6 files changed, 479 insertions(+), 3 deletions(-) diff --git a/projects/activex/axvlc.idl b/projects/activex/axvlc.idl index a1846f0ca4..78defb74f9 100644 --- a/projects/activex/axvlc.idl +++ b/projects/activex/axvlc.idl @@ -168,6 +168,28 @@ library AXVLC const int DISPID_PauseEvent = 101; const int DISPID_StopEvent = 102; + /* async events from libvlc */ + const int DISPID_NothingSpecialEvent = 200; + const int DISPID_OpeningEvent = 201; + const int DISPID_BufferingEvent = 202; + const int DISPID_PlayingEvent = 203; + const int DISPID_PausedEvent = 204; + const int DISPID_ForwardEvent = 205; + const int DISPID_BackwardEvent = 206; + const int DISPID_EncounteredErrorEvent = 207; + const int DISPID_EndReachedEvent = 208; + const int DISPID_StoppedEvent = 209; + + const int DISPID_TimeChangedEvent = 210; + const int DISPID_PositionChangedEvent = 211; + const int DISPID_SeekableChangedEvent = 212; + const int DISPID_PausableChangedEvent = 213; + + const int DISPID_MouseButtonEvent = 214; + const int DISPID_MouseMovedEvent = 215; + const int DISPID_MouseClickedEvent = 216; + const int DISPID_MouseObjectEvent = 217; + [ uuid(DF48072F-5EF8-434e-9B40-E2F3AE759B5F), helpstring("Event interface for VLC control"), @@ -182,6 +204,48 @@ library AXVLC void pause(); [id(DISPID_StopEvent), helpstring("Stopped")] void stop(); + + /* asyn events from libvlc */ + [id(DISPID_NothingSpecialEvent), helpstring("Idle state")] + void idle(); + [id(DISPID_OpeningEvent), helpstring("Opening media")] + void opening(); + [id(DISPID_BufferingEvent), helpstring("Buffering media")] + void buffering(); + [id(DISPID_PlayingEvent), helpstring("Media is playing")] + void playing(); + [id(DISPID_PausedEvent), helpstring("Media is paused")] + void paused(); + [id(DISPID_ForwardEvent), helpstring("Forward playback")] + void forward(); + [id(DISPID_BackwardEvent), helpstring("Backward playback")] + void backward(); + [id(DISPID_EncounteredErrorEvent), helpstring("An error has been encountered")] + void error(); + [id(DISPID_EndReachedEvent), helpstring("End of playback reached")] + void ended(); + [id(DISPID_StoppedEvent), helpstring("Playback stopped")] + void stopped(); + + [id(DISPID_TimeChangedEvent), helpstring("Time changed")] + void TimeChanged([in] long time); + [id(DISPID_PositionChangedEvent), helpstring("Position changed")] + void PositionChanged([in] long position); + [id(DISPID_SeekableChangedEvent), helpstring("Seek changed")] + void SeekableChanged([in] VARIANT_BOOL seekable); + [id(DISPID_PausableChangedEvent), helpstring("Pause setting changed")] + void PausableChanged([in] VARIANT_BOOL pausable); + + [id(DISPID_MouseButtonEvent), helpstring("Mouse button pressed")] + void MouseButton([in] VARIANT_BOOL btn_right, [in] VARIANT_BOOL btn_center, + [in] VARIANT_BOOL btn_left, [in] VARIANT_BOOL btn_wheel_up, + [in] VARIANT_BOOL bnt_wheel_down); + [id(DISPID_MouseMovedEvent), helpstring("Mouse moved")] + void MouseMoved([in] long x, [in] long y); + [id(DISPID_MouseClickedEvent), helpstring("Mouse clicked")] + void MouseClicked([in] VARIANT_BOOL clicked); + [id(DISPID_MouseObjectEvent), helpstring("Mouse selected holds object")] + void MouseObject([in] VARIANT_BOOL moved); }; [ @@ -619,5 +683,6 @@ library AXVLC { [default] interface IVLCControl2; interface IVLCControl; + [default, source] dispinterface DVLCEvents; }; }; diff --git a/projects/activex/axvlc.tlb b/projects/activex/axvlc.tlb index 5ddd2e11a13df28993252d91185dad036c75c64b..4bc10a0cb9ed2e3f42776fb9bbddeaf4d6ea0950 100644 GIT binary patch delta 2690 zcmYjTZ){Ul6hD34+OF+bw{@fZQJ%}hMJs8Rg-o-Mveg9$gBlh~$YkrEH&!U^Y~Mf) z*nOCU4}1VG5@Luh#u!XSf*Bu3B)SAYfKCLRI-()OEM^iSd?1kzOZ0c{yM5b9e(%0> z&hMOi?|J9F`<6a+EPd%X9dUg`M6T*Hn~yx-?<4X<`wvowaR~bQ75Wn|Y-jGg)P4*O z(w2$GYKcNXCGhN8qFD2?J|7XA9M3j{+KB=y^0l>#{f>4m+AcnDq_pTOBJbYs>S)oZ z^;NM?OKGRO#Mc^ z&DAOG+79t9hV#3`J!|N8rJDZOgV~9yMyiRN@|LJc+|e4vtgFS*FCMwpXraA`*eD`y zk2dQUAG_Czes_qid3Q=%lFo+9n6U-%i(D;8s9AVDFDkDX@Oah`s=?BMDpZ84#5wxP);LBo3^| zMd$-ax)*^%*eBZ;IQXG&{pJ8}*f0lD1c(6_P>Co4#xW!NatK_2%>y6nSN&p(|JfZ& zN<9y^iT%&=-fOHHn7E$=o*;}vSWbF~uBz!+p9h!6vtIGJfAgw1TvJ%yEXFp!c;N4C z&aGfyQ!78|6TP)9+A06^!P*nvauDV#NK{4L8?%|5!TKB~a?`Hsg;67)%^ygx&4WeO z(AscnYpTSr{FKm4kU=A2sgl&mJ~YHS6fDyL$}dP%@Q6T-gfbWDoKBdFaUdCFSHvX0Vt#Y8Z@TcUHhM ze+iGwLpR^!owJYmkFj$f-TSw%fNFG)nPwrM;M^=Vv|%b`<_C+}10yCjCXHoWz4YM% zJJLqpG*AY1v?7^@v`1{u8N(*qxa<8i7-8Gd5yQw0j*YUt6WmpFsXmoAl|559nzt&q z4U6>By4!L=eT5^HM-;_o{nYc-4(aI0Wz&a@3@0kDMI)IW;rd{bIM%?)u>q^&5`N-F)6=Tcn4=nO+2$v1EY{1i z9TQE&je{~6rim@t%pl29>M7YF`e@N8$(P5c>{dY&iCU#s9>zMQmy8^qfsxTi3b{;4 zFIbNxkqFTnJA3qWAwT_h*l;-8Hk#9~Z~Eprt;;DI;;FKZPjm>MC99D-$X|u`LCI%9 zA{}3Wia$W?#{*V!S^BGOe^C0-c}ixa-(~wl(vJ_IlDQz>bse9D$^`2r0iRqYi!y=7 z_UqD*_fN@^^w-$_R_RB#DhV|42E4YvP5RNfN?M!BOz_!+uq5CMsU#*7_-%hg`uUq| z$q@Wu94eI!bWjWxswIc=oA5iyIerB?+roG$E8I@zmaA6TCu!xr zZN)vGZEWwP20QsS>PPMd{)dq=uQs@V$(W1El*gYaB}|QW;7+-NMoHqxMYX6?YLYMo zZEjq0gEseRWw(l(LA(JB12=%1z<0p+z%2TYe!$Hw;78y#a0mDa_!*c3egS?3ego!# zyFe6(1Dt#U{d5-KUjh?4|4;DA&%X?Oob%rR|5xzu1fR!z0Q2t!pUDGnVwIJ19kHYX rQD6ud2PT0T;6A`x)PX241dIcdz%1|-Xhoglz!b0m1f1er{ICB3SN)yG delta 739 zcmYjOO=uHA6n;C|?oN`8mb%0=)EXD{Vhth05T%4rVkkvQM3Ew)hDAL{$SHUz3O$tK z(fT~}P(;Loha9Raq99t(V-W=po=OkmK?HN?K_sBxuoIdGk8j@lzV|aT{pUviiE%$? zEfdjUbFFy$L^V$2Ao>S82&^NX7>f5|$gO=jm2ZI{u`g^Th(3cH6i%lQyZfunCNMtB8E+(U>4gg0GqnG;<+E6C~oND zW|Sz0iB~asI z`p^yHZ_ujqSIMuO;sJH+Vrma*BL3^tlG8)gZ}sNC1Yb#bq7x04600$uO=rZ*XmBh2 t$ql->wh>7kx)vPCzdt6L#5d^@fZv2y;OdK2PFV(CAugZ&@gI~g1ZV&N diff --git a/projects/activex/axvlc_idl.c b/projects/activex/axvlc_idl.c index 7b1a9ba901..60804b397d 100644 --- a/projects/activex/axvlc_idl.c +++ b/projects/activex/axvlc_idl.c @@ -1,4 +1,4 @@ -/*** Autogenerated by WIDL 1.1.23 from axvlc.idl - Do not edit ***/ +/*** Autogenerated by WIDL 1.1.36 from axvlc.idl - Do not edit ***/ #include #include diff --git a/projects/activex/axvlc_idl.h b/projects/activex/axvlc_idl.h index 705ef9b762..0eb2b09a22 100644 --- a/projects/activex/axvlc_idl.h +++ b/projects/activex/axvlc_idl.h @@ -1,4 +1,4 @@ -/*** Autogenerated by WIDL 1.1.23 from axvlc.idl - Do not edit ***/ +/*** Autogenerated by WIDL 1.1.36 from axvlc.idl - Do not edit ***/ #include #include @@ -793,6 +793,42 @@ void __RPC_STUB IVLCControl_put_AutoLoop_Stub( #define DISPID_StopEvent (102) +#define DISPID_NothingSpecialEvent (200) + +#define DISPID_OpeningEvent (201) + +#define DISPID_BufferingEvent (202) + +#define DISPID_PlayingEvent (203) + +#define DISPID_PausedEvent (204) + +#define DISPID_ForwardEvent (205) + +#define DISPID_BackwardEvent (206) + +#define DISPID_EncounteredErrorEvent (207) + +#define DISPID_EndReachedEvent (208) + +#define DISPID_StoppedEvent (209) + +#define DISPID_TimeChangedEvent (210) + +#define DISPID_PositionChangedEvent (211) + +#define DISPID_SeekableChangedEvent (212) + +#define DISPID_PausableChangedEvent (213) + +#define DISPID_MouseButtonEvent (214) + +#define DISPID_MouseMovedEvent (215) + +#define DISPID_MouseClickedEvent (216) + +#define DISPID_MouseObjectEvent (217) + /***************************************************************************** * DVLCEvents dispinterface */ diff --git a/projects/activex/plugin.cpp b/projects/activex/plugin.cpp index f14ad5aac3..1b3efdd43a 100644 --- a/projects/activex/plugin.cpp +++ b/projects/activex/plugin.cpp @@ -272,7 +272,12 @@ VLCPlugin::~VLCPlugin() SysFreeString(_bstr_mrl); SysFreeString(_bstr_baseurl); - if( _p_mplayer ) { libvlc_media_player_release(_p_mplayer); _p_mplayer=NULL; } + if( _p_mplayer ) + { + player_unregister_events(); + libvlc_media_player_release(_p_mplayer); + _p_mplayer=NULL; + } if( _p_mlist ) { libvlc_media_list_release(_p_mlist); _p_mlist=NULL; } if( _p_libvlc ) { libvlc_release(_p_libvlc); _p_libvlc=NULL; } @@ -996,6 +1001,252 @@ void VLCPlugin::fireOnStopEvent(void) vlcConnectionPointContainer->fireEvent(DISPID_StopEvent, &dispparamsNoArgs); }; +/* + * Async events + */ +void VLCPlugin::fireOnIdleEvent() +{ + DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; + vlcConnectionPointContainer->fireEvent(DISPID_NothingSpecialEvent, &dispparamsNoArgs); +}; + +void VLCPlugin::fireOnOpeningEvent() +{ + DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; + vlcConnectionPointContainer->fireEvent(DISPID_OpeningEvent, &dispparamsNoArgs); +}; + +void VLCPlugin::fireOnBufferingEvent() +{ + DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; + vlcConnectionPointContainer->fireEvent(DISPID_BufferingEvent, &dispparamsNoArgs); +}; + +void VLCPlugin::fireOnPlayingEvent() +{ + DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; + vlcConnectionPointContainer->fireEvent(DISPID_PlayingEvent, &dispparamsNoArgs); +}; + +void VLCPlugin::fireOnPausedEvent() +{ + DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; + vlcConnectionPointContainer->fireEvent(DISPID_PausedEvent, &dispparamsNoArgs); +}; + +void VLCPlugin::fireOnErrorEvent() +{ + DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; + vlcConnectionPointContainer->fireEvent(DISPID_EncounteredErrorEvent, &dispparamsNoArgs); +}; + +void VLCPlugin::fireOnEndedEvent() +{ + DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; + vlcConnectionPointContainer->fireEvent(DISPID_EndReachedEvent, &dispparamsNoArgs); +}; + +void VLCPlugin::fireOnStoppedEvent() +{ + DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; + vlcConnectionPointContainer->fireEvent(DISPID_StoppedEvent, &dispparamsNoArgs); +}; + +void VLCPlugin::fireOnForwardEvent() +{ + DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; + vlcConnectionPointContainer->fireEvent(DISPID_ForwardEvent, &dispparamsNoArgs); +}; + +void VLCPlugin::fireOnBackwardEvent() +{ + DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; + vlcConnectionPointContainer->fireEvent(DISPID_BackwardEvent, &dispparamsNoArgs); +}; + +static void handle_input_state_event(const libvlc_event_t* event, void *param) +{ + VLCPlugin *plugin = (VLCPlugin*)param; + switch( event->type ) + { + case libvlc_MediaPlayerNothingSpecial: + plugin->fireOnIdleEvent(); + break; + case libvlc_MediaPlayerOpening: + plugin->fireOnOpeningEvent(); + break; + case libvlc_MediaPlayerBuffering: + plugin->fireOnBufferingEvent(); + break; + case libvlc_MediaPlayerPlaying: + plugin->fireOnPlayingEvent(); + break; + case libvlc_MediaPlayerPaused: + plugin->fireOnPausedEvent(); + break; + case libvlc_MediaPlayerStopped: + plugin->fireOnStoppedEvent(); + break; + case libvlc_MediaPlayerForward: + plugin->fireOnForwardEvent(); + break; + case libvlc_MediaPlayerBackward: + plugin->fireOnBackwardEvent(); + break; + case libvlc_MediaPlayerEndReached: + plugin->fireOnEndedEvent(); + break; + case libvlc_MediaPlayerEncounteredError: + plugin->fireOnErrorEvent(); + break; + } +} + +void VLCPlugin::fireOnTimeChangedEvent(long time) +{ + VARIANT varPos; + DISPPARAMS params = { &varPos, NULL, 1, 0 }; + varPos.vt = VT_I4; + varPos.lVal = time; + vlcConnectionPointContainer->fireEvent(DISPID_TimeChangedEvent, ¶ms); +}; + +static void handle_time_changed_event(const libvlc_event_t* event, void *param) +{ + VLCPlugin *plugin = (VLCPlugin*)param; + plugin->fireOnTimeChangedEvent(event->u.media_player_time_changed.new_time); +} + +void VLCPlugin::fireOnPositionChangedEvent(long position) +{ + VARIANT varPos; + DISPPARAMS params = { &varPos, NULL, 1, 0 }; + varPos.vt = VT_I4; + varPos.lVal = position; + vlcConnectionPointContainer->fireEvent(DISPID_PositionChangedEvent, ¶ms); +}; + +static void handle_position_changed_event(const libvlc_event_t* event, void *param) +{ + VLCPlugin *plugin = (VLCPlugin*)param; + plugin->fireOnPositionChangedEvent(event->u.media_player_position_changed.new_position); +} + +void VLCPlugin::fireOnSeekableChangedEvent(VARIANT_BOOL seekable) +{ + VARIANT varSeek; + DISPPARAMS params = { &varSeek, NULL, 1, 0 }; + varSeek.vt = VT_BOOL; + varSeek.boolVal = seekable; + vlcConnectionPointContainer->fireEvent(DISPID_SeekableChangedEvent, ¶ms); +}; + +static void handle_seekable_changed_event(const libvlc_event_t* event, void *param) +{ + VLCPlugin *plugin = (VLCPlugin*)param; + plugin->fireOnSeekableChangedEvent(event->u.media_player_seekable_changed.new_seekable); +} + +void VLCPlugin::fireOnPausableChangedEvent(VARIANT_BOOL pausable) +{ + VARIANT varPause; + DISPPARAMS params = { &varPause, NULL, 1, 0 }; + varPause.vt = VT_BOOL; + varPause.boolVal = pausable; + vlcConnectionPointContainer->fireEvent(DISPID_PausableChangedEvent, ¶ms); +}; + +static void handle_pausable_changed_event(const libvlc_event_t* event, void *param) +{ + VLCPlugin *plugin = (VLCPlugin*)param; + plugin->fireOnPausableChangedEvent(event->u.media_player_pausable_changed.new_pausable); +} + +/* mouse events */ +void VLCPlugin::fireOnMouseButtonEvent(VARIANT_BOOL btn_right, VARIANT_BOOL btn_center, + VARIANT_BOOL btn_left, VARIANT_BOOL btn_wheel_up, + VARIANT_BOOL btn_wheel_down) +{ + VARIANT varButton[5]; + DISPPARAMS params = { varButton, NULL, 5, 0 }; + varButton[0].vt = VT_BOOL; + varButton[0].boolVal = btn_right; + varButton[1].vt = VT_BOOL; + varButton[1].boolVal = btn_center; + varButton[2].vt = VT_BOOL; + varButton[2].boolVal = btn_left; + varButton[3].vt = VT_BOOL; + varButton[3].boolVal = btn_wheel_up; + varButton[4].vt = VT_BOOL; + varButton[4].boolVal = btn_wheel_down; + vlcConnectionPointContainer->fireEvent(DISPID_MouseButtonEvent, ¶ms); +}; + +void VLCPlugin::fireOnMouseMovedEvent(long x, long y) +{ + VARIANT varMoved[2]; + DISPPARAMS params = { varMoved, NULL, 3, 0 }; + varMoved[0].vt = VT_INT; + varMoved[0].intVal = x; + varMoved[1].vt = VT_INT; + varMoved[1].intVal = y; + vlcConnectionPointContainer->fireEvent(DISPID_MouseMovedEvent, ¶ms); +}; + +void VLCPlugin::fireOnMouseClickedEvent(VARIANT_BOOL clicked) +{ + VARIANT varClicked; + DISPPARAMS params = { &varClicked, NULL, 1, 0 }; + varClicked.vt = VT_BOOL; + varClicked.boolVal = clicked; + vlcConnectionPointContainer->fireEvent(DISPID_MouseClickedEvent, ¶ms); +}; + +void VLCPlugin::fireOnMouseObjectEvent(VARIANT_BOOL moved) +{ + VARIANT varMoved; + DISPPARAMS params = { &varMoved, NULL, 1, 0 }; + varMoved.vt = VT_BOOL; + varMoved.boolVal = moved; + vlcConnectionPointContainer->fireEvent(DISPID_MouseObjectEvent, ¶ms); +}; + +static void handle_mouse_button_pressed_event(const libvlc_event_t* event, void *param) +{ + VLCPlugin *plugin = (VLCPlugin*)param; + VARIANT_BOOL btn_right, btn_center, btn_left, btn_wheel_up, btn_wheel_down; +#define B(val) ((val) ? 0xFFFF : 0x0000) + btn_right = B(event->u.media_player_mouse_button.mb_right); + btn_center = B(event->u.media_player_mouse_button.mb_center); + btn_left = B(event->u.media_player_mouse_button.mb_left); + btn_wheel_up = B(event->u.media_player_mouse_button.mb_wheel_up); + btn_wheel_down = B(event->u.media_player_mouse_button.mb_wheel_down); +#undef B + plugin->fireOnMouseButtonEvent(btn_right, btn_center, btn_left, + btn_wheel_up, btn_wheel_down); +} + +static void handle_mouse_moved_event(const libvlc_event_t* event, void *param) +{ + VLCPlugin *plugin = (VLCPlugin*)param; + plugin->fireOnMouseMovedEvent(event->u.media_player_mouse_moved.x, + event->u.media_player_mouse_moved.y); +} + +static void handle_mouse_clicked_event(const libvlc_event_t* event, void *param) +{ + VLCPlugin *plugin = (VLCPlugin*)param; + plugin->fireOnMouseClickedEvent(event->u.media_player_mouse_clicked.clicked); +} + +static void handle_mouse_object_event(const libvlc_event_t* event, void *param) +{ + VLCPlugin *plugin = (VLCPlugin*)param; + plugin->fireOnMouseObjectEvent(event->u.media_player_mouse_object.moved); +} + +/* */ + bool VLCPlugin::playlist_select( int idx ) { libvlc_media_t *p_m = NULL; @@ -1018,6 +1269,7 @@ bool VLCPlugin::playlist_select( int idx ) if( _p_mplayer ) { + player_unregister_events(); libvlc_media_player_release( _p_mplayer ); _p_mplayer = NULL; } @@ -1030,6 +1282,7 @@ bool VLCPlugin::playlist_select( int idx ) if( _b_mute ) libvlc_audio_set_mute(_p_mplayer, TRUE); set_player_window(); + player_register_events(); } libvlc_media_release(p_m); @@ -1046,6 +1299,102 @@ void VLCPlugin::set_player_window() libvlc_media_player_set_hwnd(_p_mplayer,getInPlaceWindow()); } +void VLCPlugin::player_register_events() +{ + libvlc_event_manager_t *eventManager = NULL; + assert(_p_mplayer); + + eventManager = libvlc_media_player_event_manager(_p_mplayer); + if(eventManager) { + libvlc_event_attach(eventManager, libvlc_MediaPlayerNothingSpecial, + handle_input_state_event, this); + libvlc_event_attach(eventManager, libvlc_MediaPlayerOpening, + handle_input_state_event, this); + libvlc_event_attach(eventManager, libvlc_MediaPlayerBuffering, + handle_input_state_event, this); + libvlc_event_attach(eventManager, libvlc_MediaPlayerPlaying, + handle_input_state_event, this); + libvlc_event_attach(eventManager, libvlc_MediaPlayerPaused, + handle_input_state_event, this); + libvlc_event_attach(eventManager, libvlc_MediaPlayerStopped, + handle_input_state_event, this); + libvlc_event_attach(eventManager, libvlc_MediaPlayerForward, + handle_input_state_event, this); + libvlc_event_attach(eventManager, libvlc_MediaPlayerBackward, + handle_input_state_event, this); + libvlc_event_attach(eventManager, libvlc_MediaPlayerEndReached, + handle_input_state_event, this); + libvlc_event_attach(eventManager, libvlc_MediaPlayerEncounteredError, + handle_input_state_event, this); + + libvlc_event_attach(eventManager, libvlc_MediaPlayerTimeChanged, + handle_time_changed_event, this); + libvlc_event_attach(eventManager, libvlc_MediaPlayerPositionChanged, + handle_position_changed_event, this); + libvlc_event_attach(eventManager, libvlc_MediaPlayerSeekableChanged, + handle_seekable_changed_event, this); + libvlc_event_attach(eventManager, libvlc_MediaPlayerPausableChanged, + handle_pausable_changed_event, this); + + libvlc_event_attach(eventManager, libvlc_MediaPlayerMouseButton, + handle_mouse_button_pressed_event, this); + libvlc_event_attach(eventManager, libvlc_MediaPlayerMouseMoved, + handle_mouse_moved_event, this); + libvlc_event_attach(eventManager, libvlc_MediaPlayerMouseClick, + handle_mouse_clicked_event, this); + libvlc_event_attach(eventManager, libvlc_MediaPlayerMouseObject, + handle_mouse_object_event, this); + } +} + +void VLCPlugin::player_unregister_events() +{ + libvlc_event_manager_t *eventManager = NULL; + assert(_p_mplayer); + + eventManager = libvlc_media_player_event_manager(_p_mplayer); + if(eventManager) { + libvlc_event_detach(eventManager, libvlc_MediaPlayerNothingSpecial, + handle_input_state_event, this); + libvlc_event_detach(eventManager, libvlc_MediaPlayerOpening, + handle_input_state_event, this); + libvlc_event_detach(eventManager, libvlc_MediaPlayerBuffering, + handle_input_state_event, this); + libvlc_event_detach(eventManager, libvlc_MediaPlayerPlaying, + handle_input_state_event, this); + libvlc_event_detach(eventManager, libvlc_MediaPlayerPaused, + handle_input_state_event, this); + libvlc_event_detach(eventManager, libvlc_MediaPlayerStopped, + handle_input_state_event, this); + libvlc_event_detach(eventManager, libvlc_MediaPlayerForward, + handle_input_state_event, this); + libvlc_event_detach(eventManager, libvlc_MediaPlayerBackward, + handle_input_state_event, this); + libvlc_event_detach(eventManager, libvlc_MediaPlayerEndReached, + handle_input_state_event, this); + libvlc_event_detach(eventManager, libvlc_MediaPlayerEncounteredError, + handle_input_state_event, this); + + libvlc_event_detach(eventManager, libvlc_MediaPlayerTimeChanged, + handle_time_changed_event, this); + libvlc_event_detach(eventManager, libvlc_MediaPlayerPositionChanged, + handle_position_changed_event, this); + libvlc_event_detach(eventManager, libvlc_MediaPlayerSeekableChanged, + handle_seekable_changed_event, this); + libvlc_event_detach(eventManager, libvlc_MediaPlayerPausableChanged, + handle_pausable_changed_event, this); + + libvlc_event_detach(eventManager, libvlc_MediaPlayerMouseButton, + handle_mouse_button_pressed_event, this); + libvlc_event_detach(eventManager, libvlc_MediaPlayerMouseMoved, + handle_mouse_moved_event, this); + libvlc_event_detach(eventManager, libvlc_MediaPlayerMouseClick, + handle_mouse_clicked_event, this); + libvlc_event_detach(eventManager, libvlc_MediaPlayerMouseObject, + handle_mouse_object_event, this); + } +} + int VLCPlugin::playlist_add_extended_untrusted(const char *mrl, int optc, const char **optv) { int item = -1; diff --git a/projects/activex/plugin.h b/projects/activex/plugin.h index 730c57cbb1..d0776f8617 100644 --- a/projects/activex/plugin.h +++ b/projects/activex/plugin.h @@ -238,6 +238,30 @@ public: void fireOnPauseEvent(void); void fireOnStopEvent(void); + // async events; + void fireOnIdleEvent(); + void fireOnOpeningEvent(); + void fireOnBufferingEvent(); + void fireOnPlayingEvent(); + void fireOnPausedEvent(); + void fireOnErrorEvent(); + void fireOnEndedEvent(); + void fireOnStoppedEvent(); + void fireOnForwardEvent(); + void fireOnBackwardEvent(); + + void fireOnTimeChangedEvent(long time); + void fireOnPositionChangedEvent(long position); + void fireOnSeekableChangedEvent(VARIANT_BOOL seekable); + void fireOnPausableChangedEvent(VARIANT_BOOL pausable); + + void fireOnMouseButtonEvent(VARIANT_BOOL btn_right, VARIANT_BOOL btn_center, + VARIANT_BOOL btn_left, VARIANT_BOOL btn_wheel_up, + VARIANT_BOOL bnt_wheel_down); + void fireOnMouseMovedEvent(long x, long y); + void fireOnMouseClickedEvent(VARIANT_BOOL clicked); + void fireOnMouseObjectEvent(VARIANT_BOOL moved); + // controlling IUnknown interface LPUNKNOWN pUnkOuter; @@ -316,6 +340,8 @@ private: void initVLC(); bool playlist_select(int i); void set_player_window(); + void player_register_events(); + void player_unregister_events(); //implemented interfaces class VLCOleObject *vlcOleObject; -- 2.39.5