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) ...@@ -400,3 +400,14 @@ void ConnectionPointContainer_Destroy(WindowsMediaPlayer *wmp)
{ {
ConnectionPoint_Destroy(wmp->wmpocx); 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) ...@@ -307,8 +307,8 @@ static ULONG WINAPI OleObject_Release(IOleObject *iface)
if(!ref) { if(!ref) {
release_client_site(This); release_client_site(This);
ConnectionPointContainer_Destroy(This);
destroy_player(This); destroy_player(This);
ConnectionPointContainer_Destroy(This);
heap_free(This); heap_free(This);
} }
......
...@@ -20,9 +20,26 @@ ...@@ -20,9 +20,26 @@
#include "wine/debug.h" #include "wine/debug.h"
#include <nserror.h> #include <nserror.h>
#include "wmpids.h"
WINE_DEFAULT_DEBUG_CHANNEL(wmp); 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) static inline WMPMedia *impl_from_IWMPMedia(IWMPMedia *iface)
{ {
return CONTAINING_RECORD(iface, WMPMedia, IWMPMedia_iface); return CONTAINING_RECORD(iface, WMPMedia, IWMPMedia_iface);
...@@ -125,14 +142,21 @@ static HRESULT WINAPI WMPPlayer4_put_URL(IWMPPlayer4 *iface, BSTR url) ...@@ -125,14 +142,21 @@ static HRESULT WINAPI WMPPlayer4_put_URL(IWMPPlayer4 *iface, BSTR url)
if(url == NULL) { if(url == NULL) {
return E_POINTER; return E_POINTER;
} }
hres = create_media_from_url(url, &media); hres = create_media_from_url(url, &media);
if (SUCCEEDED(hres)) { if (SUCCEEDED(hres)) {
update_state(This, DISPID_WMPCOREEVENT_PLAYSTATECHANGE, wmppsTransitioning);
hres = IWMPPlayer4_put_currentMedia(iface, media); hres = IWMPPlayer4_put_currentMedia(iface, media);
IWMPMedia_Release(media); /* put will addref */ IWMPMedia_Release(media); /* put will addref */
} }
if (SUCCEEDED(hres) && This->auto_start) { if (SUCCEEDED(hres)) {
hres = IWMPControls_play(&This->IWMPControls_iface); update_state(This, DISPID_WMPCOREEVENT_PLAYSTATECHANGE, wmppsReady);
if (This->auto_start == VARIANT_TRUE) {
hres = IWMPControls_play(&This->IWMPControls_iface);
}
} }
return hres; return hres;
} }
...@@ -191,9 +215,13 @@ static HRESULT WINAPI WMPPlayer4_put_currentMedia(IWMPPlayer4 *iface, IWMPMedia ...@@ -191,9 +215,13 @@ static HRESULT WINAPI WMPPlayer4_put_currentMedia(IWMPPlayer4 *iface, IWMPMedia
if(pMedia == NULL) { if(pMedia == NULL) {
return E_POINTER; return E_POINTER;
} }
update_state(This, DISPID_WMPCOREEVENT_OPENSTATECHANGE, wmposPlaylistChanging);
if(This->wmpmedia != NULL) { if(This->wmpmedia != NULL) {
IWMPMedia_Release(This->wmpmedia); IWMPMedia_Release(This->wmpmedia);
} }
update_state(This, DISPID_WMPCOREEVENT_OPENSTATECHANGE, wmposPlaylistChanged);
update_state(This, DISPID_WMPCOREEVENT_OPENSTATECHANGE, wmposPlaylistOpenNoMedia);
This->wmpmedia = pMedia; This->wmpmedia = pMedia;
IWMPMedia_AddRef(This->wmpmedia); IWMPMedia_AddRef(This->wmpmedia);
return S_OK; return S_OK;
...@@ -1388,19 +1416,32 @@ static HRESULT WINAPI WMPControls_play(IWMPControls *iface) ...@@ -1388,19 +1416,32 @@ static HRESULT WINAPI WMPControls_play(IWMPControls *iface)
CLSCTX_INPROC_SERVER, CLSCTX_INPROC_SERVER,
&IID_IGraphBuilder, &IID_IGraphBuilder,
(void **)&This->filter_graph); (void **)&This->filter_graph);
update_state(This, DISPID_WMPCOREEVENT_OPENSTATECHANGE, wmposOpeningUnknownURL);
if (SUCCEEDED(hres)) if (SUCCEEDED(hres))
hres = IGraphBuilder_RenderFile(This->filter_graph, media->url, NULL); hres = IGraphBuilder_RenderFile(This->filter_graph, media->url, NULL);
if (SUCCEEDED(hres)) if (SUCCEEDED(hres))
hres = IGraphBuilder_QueryInterface(This->filter_graph, &IID_IMediaControl, hres = IGraphBuilder_QueryInterface(This->filter_graph, &IID_IMediaControl,
(void**)&This->media_control); (void**)&This->media_control);
if (SUCCEEDED(hres))
update_state(This, DISPID_WMPCOREEVENT_OPENSTATECHANGE, wmposMediaOpen);
} }
update_state(This, DISPID_WMPCOREEVENT_PLAYSTATECHANGE, wmppsTransitioning);
if (SUCCEEDED(hres)) if (SUCCEEDED(hres))
hres = IMediaControl_Run(This->media_control); hres = IMediaControl_Run(This->media_control);
if (hres == S_FALSE) { if (hres == S_FALSE) {
hres = S_OK; /* S_FALSE will mean that graph is transitioning and that is fine */ 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; return hres;
} }
...@@ -1419,6 +1460,8 @@ static HRESULT WINAPI WMPControls_stop(IWMPControls *iface) ...@@ -1419,6 +1460,8 @@ static HRESULT WINAPI WMPControls_stop(IWMPControls *iface)
IGraphBuilder_Release(This->filter_graph); IGraphBuilder_Release(This->filter_graph);
This->filter_graph = NULL; This->filter_graph = NULL;
This->media_control = NULL; This->media_control = NULL;
update_state(This, DISPID_WMPCOREEVENT_OPENSTATECHANGE, wmposPlaylistOpenNoMedia);
update_state(This, DISPID_WMPCOREEVENT_PLAYSTATECHANGE, wmppsStopped);
return hres; return hres;
} }
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(wmp); WINE_DEFAULT_DEBUG_CHANNEL(wmp);
HINSTANCE wmp_instance; 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) static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
{ {
......
...@@ -83,6 +83,7 @@ WMPMedia *unsafe_impl_from_IWMPMedia(IWMPMedia *iface) DECLSPEC_HIDDEN; ...@@ -83,6 +83,7 @@ WMPMedia *unsafe_impl_from_IWMPMedia(IWMPMedia *iface) DECLSPEC_HIDDEN;
HRESULT create_media_from_url(BSTR url, IWMPMedia **ppMedia) DECLSPEC_HIDDEN; HRESULT create_media_from_url(BSTR url, IWMPMedia **ppMedia) DECLSPEC_HIDDEN;
void ConnectionPointContainer_Init(WindowsMediaPlayer *wmp) DECLSPEC_HIDDEN; void ConnectionPointContainer_Init(WindowsMediaPlayer *wmp) DECLSPEC_HIDDEN;
void ConnectionPointContainer_Destroy(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; HRESULT WINAPI WMPFactory_CreateInstance(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
......
...@@ -706,6 +706,7 @@ SOURCES = \ ...@@ -706,6 +706,7 @@ SOURCES = \
wmium.h \ wmium.h \
wmiutils.idl \ wmiutils.idl \
wmp.idl \ wmp.idl \
wmpids.h \
wmsbuffer.idl \ wmsbuffer.idl \
wmsdk.h \ wmsdk.h \
wmsdkidl.idl \ 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