_i_codepage(CP_ACP),
_b_usermode(TRUE)
{
+ /*
+ ** bump refcount to avoid recursive release from
+ ** following interfaces when releasing this interface
+ */
+ AddRef();
p_class->AddRef();
vlcOleControl = new VLCOleControl(this);
VLCPlugin::~VLCPlugin()
{
- /*
- ** bump refcount to avoid recursive release from
- ** following interfaces when releasing this interface
- */
- AddRef();
-
delete vlcSupportErrorInfo;
delete vlcOleObject;
delete vlcDataObject;
if( _p_mplayer )
{
+ if( isPlaying() )
+ playlist_stop();
+
player_unregister_events();
libvlc_media_player_release(_p_mplayer);
_p_mplayer=NULL;
if( _p_libvlc ) { libvlc_release(_p_libvlc); _p_libvlc=NULL; }
_p_class->Release();
+ Release();
};
STDMETHODIMP VLCPlugin::QueryInterface(REFIID riid, void **ppv)
{
TCHAR w_progpath[MAX_PATH];
DWORD len = GetModuleFileName(DllGetModule(), w_progpath, MAX_PATH);
+ w_progpath[MAX_PATH-1] = '\0';
if( len > 0 )
{
len = WideCharToMultiByte(CP_UTF8, 0, w_progpath, len, p_progpath,
if( RegQueryValueEx( h_key, TEXT("InstallDir"), 0, &i_type,
(LPBYTE)w_pluginpath, &i_data ) == ERROR_SUCCESS )
{
+ w_pluginpath[MAX_PATH-1] = '\0';
if( i_type == REG_SZ )
{
if( WideCharToMultiByte(CP_UTF8, 0, w_pluginpath, -1, p_pluginpath,
/*
* Async events
*/
-void VLCPlugin::fireOnIdleEvent()
+void VLCPlugin::fireOnMediaPlayerNothingSpecialEvent()
{
DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
- vlcConnectionPointContainer->fireEvent(DISPID_NothingSpecialEvent, &dispparamsNoArgs);
+ vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerNothingSpecialEvent, &dispparamsNoArgs);
};
-void VLCPlugin::fireOnOpeningEvent()
+void VLCPlugin::fireOnMediaPlayerOpeningEvent()
{
DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
- vlcConnectionPointContainer->fireEvent(DISPID_OpeningEvent, &dispparamsNoArgs);
+ vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerOpeningEvent, &dispparamsNoArgs);
};
-void VLCPlugin::fireOnBufferingEvent()
+void VLCPlugin::fireOnMediaPlayerBufferingEvent()
{
DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
- vlcConnectionPointContainer->fireEvent(DISPID_BufferingEvent, &dispparamsNoArgs);
+ vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerBufferingEvent, &dispparamsNoArgs);
};
-void VLCPlugin::fireOnPlayingEvent()
+void VLCPlugin::fireOnMediaPlayerPlayingEvent()
{
DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
- vlcConnectionPointContainer->fireEvent(DISPID_PlayingEvent, &dispparamsNoArgs);
+ vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerPlayingEvent, &dispparamsNoArgs);
};
-void VLCPlugin::fireOnPausedEvent()
+void VLCPlugin::fireOnMediaPlayerPausedEvent()
{
DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
- vlcConnectionPointContainer->fireEvent(DISPID_PausedEvent, &dispparamsNoArgs);
+ vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerPausedEvent, &dispparamsNoArgs);
};
-void VLCPlugin::fireOnErrorEvent()
+void VLCPlugin::fireOnMediaPlayerEncounteredErrorEvent()
{
DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
- vlcConnectionPointContainer->fireEvent(DISPID_EncounteredErrorEvent, &dispparamsNoArgs);
+ vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerEncounteredErrorEvent, &dispparamsNoArgs);
};
-void VLCPlugin::fireOnEndedEvent()
+void VLCPlugin::fireOnMediaPlayerEndReachedEvent()
{
DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
- vlcConnectionPointContainer->fireEvent(DISPID_EndReachedEvent, &dispparamsNoArgs);
+ vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerEndReachedEvent, &dispparamsNoArgs);
};
-void VLCPlugin::fireOnStoppedEvent()
+void VLCPlugin::fireOnMediaPlayerStoppedEvent()
{
DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
- vlcConnectionPointContainer->fireEvent(DISPID_StoppedEvent, &dispparamsNoArgs);
+ vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerStoppedEvent, &dispparamsNoArgs);
};
-void VLCPlugin::fireOnForwardEvent()
+void VLCPlugin::fireOnMediaPlayerForwardEvent()
{
DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
- vlcConnectionPointContainer->fireEvent(DISPID_ForwardEvent, &dispparamsNoArgs);
+ vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerForwardEvent, &dispparamsNoArgs);
};
-void VLCPlugin::fireOnBackwardEvent()
+void VLCPlugin::fireOnMediaPlayerBackwardEvent()
{
DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
- vlcConnectionPointContainer->fireEvent(DISPID_BackwardEvent, &dispparamsNoArgs);
+ vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerBackwardEvent, &dispparamsNoArgs);
};
static void handle_input_state_event(const libvlc_event_t* event, void *param)
switch( event->type )
{
case libvlc_MediaPlayerNothingSpecial:
- plugin->fireOnIdleEvent();
+ plugin->fireOnMediaPlayerNothingSpecialEvent();
break;
case libvlc_MediaPlayerOpening:
- plugin->fireOnOpeningEvent();
+ plugin->fireOnMediaPlayerOpeningEvent();
break;
case libvlc_MediaPlayerBuffering:
- plugin->fireOnBufferingEvent();
+ plugin->fireOnMediaPlayerBufferingEvent();
break;
case libvlc_MediaPlayerPlaying:
- plugin->fireOnPlayingEvent();
+ plugin->fireOnMediaPlayerPlayingEvent();
break;
case libvlc_MediaPlayerPaused:
- plugin->fireOnPausedEvent();
+ plugin->fireOnMediaPlayerPausedEvent();
break;
case libvlc_MediaPlayerStopped:
- plugin->fireOnStoppedEvent();
+ plugin->fireOnMediaPlayerStoppedEvent();
break;
case libvlc_MediaPlayerForward:
- plugin->fireOnForwardEvent();
+ plugin->fireOnMediaPlayerForwardEvent();
break;
case libvlc_MediaPlayerBackward:
- plugin->fireOnBackwardEvent();
+ plugin->fireOnMediaPlayerBackwardEvent();
break;
case libvlc_MediaPlayerEndReached:
- plugin->fireOnEndedEvent();
+ plugin->fireOnMediaPlayerEndReachedEvent();
break;
case libvlc_MediaPlayerEncounteredError:
- plugin->fireOnErrorEvent();
+ plugin->fireOnMediaPlayerEncounteredErrorEvent();
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);
+void VLCPlugin::fireOnMediaPlayerTimeChangedEvent(long time)
+{
+ 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 = time;
+ params.rgdispidNamedArgs = NULL;
+ params.cNamedArgs = 0;
+ vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerTimeChangedEvent, ¶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);
+ plugin->fireOnMediaPlayerTimeChangedEvent(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);
+void VLCPlugin::fireOnMediaPlayerPositionChangedEvent(long position)
+{
+ 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 = position;
+ params.rgdispidNamedArgs = NULL;
+ params.cNamedArgs = 0;
+ vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerPositionChangedEvent, ¶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);
+ plugin->fireOnMediaPlayerPositionChangedEvent(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);
+#define B(val) ((val) ? 0xFFFF : 0x0000)
+void VLCPlugin::fireOnMediaPlayerSeekableChangedEvent(VARIANT_BOOL seekable)
+{
+ 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_BOOL;
+ params.rgvarg[0].boolVal = seekable;
+ params.rgdispidNamedArgs = NULL;
+ params.cNamedArgs = 0;
+ vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerSeekableChangedEvent, ¶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);
+ plugin->fireOnMediaPlayerSeekableChangedEvent(B(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);
+void VLCPlugin::fireOnMediaPlayerPausableChangedEvent(VARIANT_BOOL pausable)
+{
+ 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_BOOL;
+ params.rgvarg[0].boolVal = pausable;
+ params.rgdispidNamedArgs = NULL;
+ params.cNamedArgs = 0;
+ vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerPausableChangedEvent, ¶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);
+ plugin->fireOnMediaPlayerPausableChangedEvent(B(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);
-}
/* */
if( _p_mplayer )
{
+ if( isPlaying() )
+ playlist_stop();
player_unregister_events();
libvlc_media_player_release( _p_mplayer );
_p_mplayer = NULL;
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);
}
}
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;
- libvlc_media_t *p_m = libvlc_media_new(_p_libvlc,mrl);
+ libvlc_media_t *p_m = libvlc_media_new_location(_p_libvlc,mrl);
if( !p_m )
return -1;