Commit 7177e3cb authored by Pierre Lamot's avatar Pierre Lamot Committed by Jean-Baptiste Kempf

activex: add method to allow stopping the player asynchonously

Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent 5cd1ab48
......@@ -90,6 +90,7 @@ library AXVLC
const int DISPID_MediaPlayerMutedEvent = 219;
const int DISPID_MediaPlayerUnmutedEvent = 220;
const int DISPID_MediaPlayerAudioVolumeEvent = 221;
const int DISPID_MediaPlayerStopAsyncDoneEvent = 222;
[
uuid(DF48072F-5EF8-434e-9B40-E2F3AE759B5F),
......@@ -120,6 +121,8 @@ library AXVLC
void MediaPlayerEndReached();
[id(DISPID_MediaPlayerStoppedEvent), helpstring("Playback stopped")]
void MediaPlayerStopped();
[id(DISPID_MediaPlayerStopAsyncDoneEvent), helpstring("Playback stop async done")]
void MediaPlayerStopAsyncDone();
[id(DISPID_MediaPlayerTimeChangedEvent), helpstring("Time changed")]
void MediaPlayerTimeChanged([in] long time);
......@@ -335,6 +338,9 @@ library AXVLC
[helpstring("Stop current clip.")]
HRESULT stop();
[helpstring("Stop current clip asynchronously.")]
HRESULT stop_async();
[helpstring("Advance to next item in playlist.")]
HRESULT next();
......
......@@ -1024,6 +1024,13 @@ void VLCPlugin::fireOnMediaPlayerStoppedEvent()
vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerStoppedEvent, &dispparamsNoArgs);
};
void VLCPlugin::fireOnMediaPlayerStopAsyncDoneEvent()
{
DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerStopAsyncDoneEvent, &dispparamsNoArgs);
};
void VLCPlugin::fireOnMediaPlayerForwardEvent()
{
DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
......
......@@ -250,6 +250,7 @@ public:
void fireOnMediaPlayerEncounteredErrorEvent();
void fireOnMediaPlayerEndReachedEvent();
void fireOnMediaPlayerStoppedEvent();
void fireOnMediaPlayerStopAsyncDoneEvent();
void fireOnMediaPlayerTimeChangedEvent(libvlc_time_t time);
void fireOnMediaPlayerPositionChangedEvent(float position);
......
......@@ -910,6 +910,30 @@ STDMETHODIMP VLCPlaylistItems::remove(long item)
}
/****************************************************************************/
enum PlaylistAsyncMessages
{
PM_INPUT_STOP = WM_USER +1,
PM_DESTROY
};
VLCPlaylist::VLCPlaylist(VLCPlugin *p):
VLCInterface<VLCPlaylist,IVLCPlaylist>(p),
_p_vlcplaylistitems(new VLCPlaylistItems(p))
{
_async_thread = CreateThread ( NULL , 0 ,
(LPTHREAD_START_ROUTINE)VLCPlaylist::async_handler_cb,
(LPVOID)this , 0, &_async_thread_id );
}
VLCPlaylist::~VLCPlaylist()
{
PostThreadMessage(_async_thread_id, PM_DESTROY, 0, 0);
WaitForSingleObject(_async_thread, INFINITE);
CloseHandle (_async_thread);
delete _p_vlcplaylistitems;
}
STDMETHODIMP VLCPlaylist::get_itemCount(long* count)
{
......@@ -1041,6 +1065,12 @@ STDMETHODIMP VLCPlaylist::stop()
return S_OK;
}
STDMETHODIMP VLCPlaylist::stop_async()
{
PostThreadMessage(_async_thread_id, PM_INPUT_STOP, 0, 0);
return S_OK;
}
STDMETHODIMP VLCPlaylist::next()
{
_plug->get_player().mlp().next();
......@@ -1089,6 +1119,36 @@ STDMETHODIMP VLCPlaylist::parse(long options, long timeout, long *status)
return S_OK;
}
void VLCPlaylist::async_handler_cb(LPVOID obj)
{
VLCPlaylist* that = (VLCPlaylist*) obj;
that->async_handler();
}
void VLCPlaylist::async_handler()
{
MSG msg;
bool b_quit = false;
while (!b_quit && GetMessage(&msg, 0, 0, 0))
{
switch(msg.message)
{
case PM_INPUT_STOP:
this->stop();
_plug->fireOnMediaPlayerStopAsyncDoneEvent();
break;
case PM_DESTROY:
b_quit = true;
break;
default:
TranslateMessage(&msg);
DispatchMessage(&msg);
break;
}
}
}
/****************************************************************************/
STDMETHODIMP VLCSubtitle::get_track(long* spu)
......
......@@ -289,10 +289,8 @@ public:
class VLCPlaylist: public VLCInterface<VLCPlaylist,IVLCPlaylist>
{
public:
VLCPlaylist(VLCPlugin *p):
VLCInterface<VLCPlaylist,IVLCPlaylist>(p),
_p_vlcplaylistitems(new VLCPlaylistItems(p)) { }
virtual ~VLCPlaylist() { delete _p_vlcplaylistitems; }
VLCPlaylist(VLCPlugin *p);
virtual ~VLCPlaylist();
// IVLCPlaylist methods
STDMETHODIMP get_itemCount(long*);
......@@ -304,6 +302,7 @@ public:
STDMETHODIMP pause();
STDMETHODIMP togglePause();
STDMETHODIMP stop();
STDMETHODIMP stop_async();
STDMETHODIMP next();
STDMETHODIMP prev();
STDMETHODIMP clear();
......@@ -311,8 +310,14 @@ public:
STDMETHODIMP get_items(IVLCPlaylistItems**);
STDMETHODIMP parse(long options, long timeout, long* status);
private:
static void async_handler_cb(LPVOID obj);
void async_handler();
private:
VLCPlaylistItems* _p_vlcplaylistitems;
HANDLE _async_thread;
DWORD _async_thread_id;
};
class VLCSubtitle: public VLCInterface<VLCSubtitle,IVLCSubtitle>
......
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