Commit 1ec43ebd authored by Anton Romanov's avatar Anton Romanov Committed by Alexandre Julliard

wmp: Add OPEN/PLAY state change notifications.

parent 1df478b7
......@@ -400,3 +400,14 @@ void ConnectionPointContainer_Destroy(WindowsMediaPlayer *wmp)
{
ConnectionPoint_Destroy(wmp->wmpocx);
}
void call_sink(ConnectionPoint *This, DISPID dispid, DISPPARAMS *dispparams)
{
DWORD i;
for(i=0; i<This->sinks_size; i++) {
if(This->sinks[i])
IDispatch_Invoke(This->sinks[i], dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
DISPATCH_METHOD, dispparams, NULL, NULL, NULL);
}
}
......@@ -307,8 +307,8 @@ static ULONG WINAPI OleObject_Release(IOleObject *iface)
if(!ref) {
release_client_site(This);
ConnectionPointContainer_Destroy(This);
destroy_player(This);
ConnectionPointContainer_Destroy(This);
heap_free(This);
}
......
......@@ -20,9 +20,26 @@
#include "wine/debug.h"
#include <nserror.h>
#include "wmpids.h"
WINE_DEFAULT_DEBUG_CHANNEL(wmp);
static void update_state(WindowsMediaPlayer *wmp, LONG type, LONG state)
{
DISPPARAMS dispparams;
VARIANTARG params[1];
dispparams.cArgs = 1;
dispparams.cNamedArgs = 0;
dispparams.rgdispidNamedArgs = NULL;
dispparams.rgvarg = params;
V_VT(params) = VT_UI4;
V_UI4(params) = state;
call_sink(wmp->wmpocx, type, &dispparams);
}
static inline WMPMedia *impl_from_IWMPMedia(IWMPMedia *iface)
{
return CONTAINING_RECORD(iface, WMPMedia, IWMPMedia_iface);
......@@ -125,14 +142,21 @@ static HRESULT WINAPI WMPPlayer4_put_URL(IWMPPlayer4 *iface, BSTR url)
if(url == NULL) {
return E_POINTER;
}
hres = create_media_from_url(url, &media);
if (SUCCEEDED(hres)) {
update_state(This, DISPID_WMPCOREEVENT_PLAYSTATECHANGE, wmppsTransitioning);
hres = IWMPPlayer4_put_currentMedia(iface, media);
IWMPMedia_Release(media); /* put will addref */
}
if (SUCCEEDED(hres) && This->auto_start) {
if (SUCCEEDED(hres)) {
update_state(This, DISPID_WMPCOREEVENT_PLAYSTATECHANGE, wmppsReady);
if (This->auto_start == VARIANT_TRUE) {
hres = IWMPControls_play(&This->IWMPControls_iface);
}
}
return hres;
}
......@@ -191,9 +215,13 @@ static HRESULT WINAPI WMPPlayer4_put_currentMedia(IWMPPlayer4 *iface, IWMPMedia
if(pMedia == NULL) {
return E_POINTER;
}
update_state(This, DISPID_WMPCOREEVENT_OPENSTATECHANGE, wmposPlaylistChanging);
if(This->wmpmedia != NULL) {
IWMPMedia_Release(This->wmpmedia);
}
update_state(This, DISPID_WMPCOREEVENT_OPENSTATECHANGE, wmposPlaylistChanged);
update_state(This, DISPID_WMPCOREEVENT_OPENSTATECHANGE, wmposPlaylistOpenNoMedia);
This->wmpmedia = pMedia;
IWMPMedia_AddRef(This->wmpmedia);
return S_OK;
......@@ -1388,19 +1416,32 @@ static HRESULT WINAPI WMPControls_play(IWMPControls *iface)
CLSCTX_INPROC_SERVER,
&IID_IGraphBuilder,
(void **)&This->filter_graph);
update_state(This, DISPID_WMPCOREEVENT_OPENSTATECHANGE, wmposOpeningUnknownURL);
if (SUCCEEDED(hres))
hres = IGraphBuilder_RenderFile(This->filter_graph, media->url, NULL);
if (SUCCEEDED(hres))
hres = IGraphBuilder_QueryInterface(This->filter_graph, &IID_IMediaControl,
(void**)&This->media_control);
if (SUCCEEDED(hres))
update_state(This, DISPID_WMPCOREEVENT_OPENSTATECHANGE, wmposMediaOpen);
}
update_state(This, DISPID_WMPCOREEVENT_PLAYSTATECHANGE, wmppsTransitioning);
if (SUCCEEDED(hres))
hres = IMediaControl_Run(This->media_control);
if (hres == S_FALSE) {
hres = S_OK; /* S_FALSE will mean that graph is transitioning and that is fine */
}
if (SUCCEEDED(hres)) {
update_state(This, DISPID_WMPCOREEVENT_PLAYSTATECHANGE, wmppsPlaying);
} else {
update_state(This, DISPID_WMPCOREEVENT_PLAYSTATECHANGE, wmppsUndefined);
}
return hres;
}
......@@ -1419,6 +1460,8 @@ static HRESULT WINAPI WMPControls_stop(IWMPControls *iface)
IGraphBuilder_Release(This->filter_graph);
This->filter_graph = NULL;
This->media_control = NULL;
update_state(This, DISPID_WMPCOREEVENT_OPENSTATECHANGE, wmposPlaylistOpenNoMedia);
update_state(This, DISPID_WMPCOREEVENT_PLAYSTATECHANGE, wmppsStopped);
return hres;
}
......
......@@ -25,6 +25,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(wmp);
HINSTANCE wmp_instance;
DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
{
......
......@@ -83,6 +83,7 @@ WMPMedia *unsafe_impl_from_IWMPMedia(IWMPMedia *iface) DECLSPEC_HIDDEN;
HRESULT create_media_from_url(BSTR url, IWMPMedia **ppMedia) DECLSPEC_HIDDEN;
void ConnectionPointContainer_Init(WindowsMediaPlayer *wmp) DECLSPEC_HIDDEN;
void ConnectionPointContainer_Destroy(WindowsMediaPlayer *wmp) DECLSPEC_HIDDEN;
void call_sink(ConnectionPoint *This, DISPID dispid, DISPPARAMS *dispparams) DECLSPEC_HIDDEN;
HRESULT WINAPI WMPFactory_CreateInstance(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
......
......@@ -706,6 +706,7 @@ SOURCES = \
wmium.h \
wmiutils.idl \
wmp.idl \
wmpids.h \
wmsbuffer.idl \
wmsdk.h \
wmsdkidl.idl \
......
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
/* WMPCoreEvents */
#define DISPID_WMPCOREEVENT_OPENSTATECHANGE 5001
#define DISPID_WMPCOREEVENT_STATUSCHANGE 5002
#define DISPID_WMPCOREEVENT_PLAYSTATECHANGE 5101
#define DISPID_WMPCOREEVENT_MEDIACHANGE 5802
#define DISPID_WMPCOREEVENT_CURRENTITEMCHANGE 5806
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