mstask: Use wide-char string literals.
[wine.git] / dlls / wmp / player.c
blob1da81b17a26a1e11668472f545eecfdd8169c545
1 /*
2 * Copyright 2014 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "wmp_private.h"
21 #include "wine/debug.h"
22 #include <nserror.h>
23 #include "wmpids.h"
24 #include "shlwapi.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(wmp);
28 static ATOM player_msg_class;
29 static INIT_ONCE class_init_once;
30 static UINT WM_WMPEVENT;
32 static void update_state(WindowsMediaPlayer *wmp, LONG type, LONG state)
34 DISPPARAMS dispparams;
35 VARIANTARG params[1];
37 dispparams.cArgs = 1;
38 dispparams.cNamedArgs = 0;
39 dispparams.rgdispidNamedArgs = NULL;
40 dispparams.rgvarg = params;
42 V_VT(params) = VT_UI4;
43 V_UI4(params) = state;
45 call_sink(wmp->wmpocx, type, &dispparams);
48 static inline WMPPlaylist *impl_from_IWMPPlaylist(IWMPPlaylist *iface)
50 return CONTAINING_RECORD(iface, WMPPlaylist, IWMPPlaylist_iface);
53 static inline WMPMedia *impl_from_IWMPMedia(IWMPMedia *iface)
55 return CONTAINING_RECORD(iface, WMPMedia, IWMPMedia_iface);
58 static inline WindowsMediaPlayer *impl_from_IWMPNetwork(IWMPNetwork *iface)
60 return CONTAINING_RECORD(iface, WindowsMediaPlayer, IWMPNetwork_iface);
63 static inline WindowsMediaPlayer *impl_from_IWMPPlayer4(IWMPPlayer4 *iface)
65 return CONTAINING_RECORD(iface, WindowsMediaPlayer, IWMPPlayer4_iface);
68 static inline WindowsMediaPlayer *impl_from_IWMPPlayer(IWMPPlayer *iface)
70 return CONTAINING_RECORD(iface, WindowsMediaPlayer, IWMPPlayer_iface);
73 static inline WindowsMediaPlayer *impl_from_IWMPControls(IWMPControls *iface)
75 return CONTAINING_RECORD(iface, WindowsMediaPlayer, IWMPControls_iface);
78 static HRESULT WINAPI WMPPlayer4_QueryInterface(IWMPPlayer4 *iface, REFIID riid, void **ppv)
80 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
81 return IOleObject_QueryInterface(&This->IOleObject_iface, riid, ppv);
84 static ULONG WINAPI WMPPlayer4_AddRef(IWMPPlayer4 *iface)
86 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
87 return IOleObject_AddRef(&This->IOleObject_iface);
90 static ULONG WINAPI WMPPlayer4_Release(IWMPPlayer4 *iface)
92 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
93 return IOleObject_Release(&This->IOleObject_iface);
96 static HRESULT WINAPI WMPPlayer4_GetTypeInfoCount(IWMPPlayer4 *iface, UINT *pctinfo)
98 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
99 FIXME("(%p)->(%p)\n", This, pctinfo);
100 return E_NOTIMPL;
103 static HRESULT WINAPI WMPPlayer4_GetTypeInfo(IWMPPlayer4 *iface, UINT iTInfo,
104 LCID lcid, ITypeInfo **ppTInfo)
106 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
107 FIXME("(%p)->(%u %d %p)\n", This, iTInfo, lcid, ppTInfo);
108 return E_NOTIMPL;
111 static HRESULT WINAPI WMPPlayer4_GetIDsOfNames(IWMPPlayer4 *iface, REFIID riid,
112 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
114 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
115 FIXME("(%p)->(%s %p %u %d %p)\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
116 return E_NOTIMPL;
119 static HRESULT WINAPI WMPPlayer4_Invoke(IWMPPlayer4 *iface, DISPID dispIdMember,
120 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
121 EXCEPINFO *pExcepInfo, UINT *puArgErr)
123 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
124 FIXME("(%p)->(%d %s %d %x %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid), lcid,
125 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
126 return E_NOTIMPL;
129 static HRESULT WINAPI WMPPlayer4_close(IWMPPlayer4 *iface)
131 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
132 FIXME("(%p)\n", This);
133 return E_NOTIMPL;
136 static HRESULT WINAPI WMPPlayer4_get_URL(IWMPPlayer4 *iface, BSTR *url)
138 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
140 TRACE("(%p)->(%p)\n", This, url);
142 if (!This->media)
143 return return_bstr(L"", url);
145 return return_bstr(This->media->url, url);
148 static HRESULT WINAPI WMPPlayer4_put_URL(IWMPPlayer4 *iface, BSTR url)
150 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
151 IWMPMedia *media;
152 HRESULT hres;
154 TRACE("(%p)->(%s)\n", This, debugstr_w(url));
156 hres = create_media_from_url(url, 0.0, &media);
158 if (SUCCEEDED(hres)) {
159 update_state(This, DISPID_WMPCOREEVENT_PLAYSTATECHANGE, wmppsTransitioning);
160 hres = IWMPPlayer4_put_currentMedia(iface, media);
161 IWMPMedia_Release(media); /* put will addref */
163 if (SUCCEEDED(hres)) {
164 update_state(This, DISPID_WMPCOREEVENT_PLAYSTATECHANGE, wmppsReady);
165 if (This->auto_start == VARIANT_TRUE)
166 IWMPControls_play(&This->IWMPControls_iface);
169 return hres;
172 static HRESULT WINAPI WMPPlayer4_get_openState(IWMPPlayer4 *iface, WMPOpenState *pwmpos)
174 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
175 FIXME("(%p)->(%p)\n", This, pwmpos);
176 return E_NOTIMPL;
179 static HRESULT WINAPI WMPPlayer4_get_playState(IWMPPlayer4 *iface, WMPPlayState *pwmpps)
181 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
182 FIXME("(%p)->(%p)\n", This, pwmpps);
183 return E_NOTIMPL;
186 static HRESULT WINAPI WMPPlayer4_get_controls(IWMPPlayer4 *iface, IWMPControls **ppControl)
188 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
190 TRACE("(%p)->(%p)\n", This, ppControl);
192 IWMPControls_AddRef(&This->IWMPControls_iface);
193 *ppControl = &This->IWMPControls_iface;
194 return S_OK;
197 static HRESULT WINAPI WMPPlayer4_get_settings(IWMPPlayer4 *iface, IWMPSettings **ppSettings)
199 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
201 TRACE("(%p)->(%p)\n", This, ppSettings);
203 IWMPSettings_AddRef(&This->IWMPSettings_iface);
204 *ppSettings = &This->IWMPSettings_iface;
205 return S_OK;
208 static HRESULT WINAPI WMPPlayer4_get_currentMedia(IWMPPlayer4 *iface, IWMPMedia **media)
210 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
212 TRACE("(%p)->(%p)\n", This, media);
214 *media = NULL;
216 if (This->media == NULL)
217 return S_FALSE;
219 return create_media_from_url(This->media->url, This->media->duration, media);
222 static HRESULT WINAPI WMPPlayer4_put_currentMedia(IWMPPlayer4 *iface, IWMPMedia *pMedia)
224 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
225 TRACE("(%p)->(%p)\n", This, pMedia);
227 if(pMedia == NULL) {
228 return E_POINTER;
230 update_state(This, DISPID_WMPCOREEVENT_OPENSTATECHANGE, wmposPlaylistChanging);
231 if(This->media != NULL) {
232 IWMPControls_stop(&This->IWMPControls_iface);
233 IWMPMedia_Release(&This->media->IWMPMedia_iface);
235 update_state(This, DISPID_WMPCOREEVENT_OPENSTATECHANGE, wmposPlaylistChanged);
236 update_state(This, DISPID_WMPCOREEVENT_OPENSTATECHANGE, wmposPlaylistOpenNoMedia);
238 IWMPMedia_AddRef(pMedia);
239 This->media = unsafe_impl_from_IWMPMedia(pMedia);
240 return S_OK;
243 static HRESULT WINAPI WMPPlayer4_get_mediaCollection(IWMPPlayer4 *iface, IWMPMediaCollection **ppMediaCollection)
245 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
246 FIXME("(%p)->(%p)\n", This, ppMediaCollection);
247 return E_NOTIMPL;
250 static HRESULT WINAPI WMPPlayer4_get_playlistCollection(IWMPPlayer4 *iface, IWMPPlaylistCollection **ppPlaylistCollection)
252 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
253 FIXME("(%p)->(%p)\n", This, ppPlaylistCollection);
254 return E_NOTIMPL;
257 static HRESULT WINAPI WMPPlayer4_get_versionInfo(IWMPPlayer4 *iface, BSTR *version)
259 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
261 TRACE("(%p)->(%p)\n", This, version);
263 if (!version)
264 return E_POINTER;
266 return return_bstr(L"12.0.7601.16982", version);
269 static HRESULT WINAPI WMPPlayer4_launchURL(IWMPPlayer4 *iface, BSTR url)
271 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
272 FIXME("(%p)->(%s)\n", This, debugstr_w(url));
273 return E_NOTIMPL;
276 static HRESULT WINAPI WMPPlayer4_get_network(IWMPPlayer4 *iface, IWMPNetwork **ppQNI)
278 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
279 TRACE("(%p)->(%p)\n", This, ppQNI);
281 IWMPNetwork_AddRef(&This->IWMPNetwork_iface);
282 *ppQNI = &This->IWMPNetwork_iface;
283 return S_OK;
286 static HRESULT WINAPI WMPPlayer4_get_currentPlaylist(IWMPPlayer4 *iface, IWMPPlaylist **playlist)
288 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
290 TRACE("(%p)->(%p)\n", This, playlist);
292 *playlist = NULL;
294 if (This->playlist == NULL)
295 return S_FALSE;
297 return create_playlist(This->playlist->name, This->playlist->url, This->playlist->count, playlist);
300 static HRESULT WINAPI WMPPlayer4_put_currentPlaylist(IWMPPlayer4 *iface, IWMPPlaylist *pPL)
302 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
303 FIXME("(%p)->(%p)\n", This, pPL);
304 return E_NOTIMPL;
307 static HRESULT WINAPI WMPPlayer4_get_cdromCollection(IWMPPlayer4 *iface, IWMPCdromCollection **ppCdromCollection)
309 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
310 FIXME("(%p)->(%p)\n", This, ppCdromCollection);
311 return E_NOTIMPL;
314 static HRESULT WINAPI WMPPlayer4_get_closedCaption(IWMPPlayer4 *iface, IWMPClosedCaption **ppClosedCaption)
316 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
317 FIXME("(%p)->(%p)\n", This, ppClosedCaption);
318 return E_NOTIMPL;
321 static HRESULT WINAPI WMPPlayer4_get_isOnline(IWMPPlayer4 *iface, VARIANT_BOOL *pfOnline)
323 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
324 FIXME("(%p)->(%p)\n", This, pfOnline);
325 return E_NOTIMPL;
328 static HRESULT WINAPI WMPPlayer4_get_Error(IWMPPlayer4 *iface, IWMPError **ppError)
330 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
331 FIXME("(%p)->(%p)\n", This, ppError);
332 return E_NOTIMPL;
335 static HRESULT WINAPI WMPPlayer4_get_Status(IWMPPlayer4 *iface, BSTR *pbstrStatus)
337 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
338 FIXME("(%p)->(%p)\n", This, pbstrStatus);
339 return E_NOTIMPL;
342 static HRESULT WINAPI WMPPlayer4_get_dvd(IWMPPlayer4 *iface, IWMPDVD **ppDVD)
344 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
345 FIXME("(%p)->(%p)\n", This, ppDVD);
346 return E_NOTIMPL;
349 static HRESULT WINAPI WMPPlayer4_newPlaylist(IWMPPlayer4 *iface, BSTR name, BSTR url, IWMPPlaylist **playlist)
351 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
353 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(name), debugstr_w(url), playlist);
355 /* FIXME: count should be the number of items in the playlist */
356 return create_playlist(name, url, 0, playlist);
359 static HRESULT WINAPI WMPPlayer4_newMedia(IWMPPlayer4 *iface, BSTR url, IWMPMedia **media)
361 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
363 TRACE("(%p)->(%s %p)\n", This, debugstr_w(url), media);
365 return create_media_from_url(url, 0.0, media);
368 static HRESULT WINAPI WMPPlayer4_get_enabled(IWMPPlayer4 *iface, VARIANT_BOOL *pbEnabled)
370 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
371 FIXME("(%p)->(%p)\n", This, pbEnabled);
372 return E_NOTIMPL;
375 static HRESULT WINAPI WMPPlayer4_put_enabled(IWMPPlayer4 *iface, VARIANT_BOOL enabled)
377 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
378 FIXME("(%p)->(%x)\n", This, enabled);
379 return E_NOTIMPL;
382 static HRESULT WINAPI WMPPlayer4_get_fullScreen(IWMPPlayer4 *iface, VARIANT_BOOL *pbFullScreen)
384 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
385 FIXME("(%p)->(%p)\n", This, pbFullScreen);
386 return E_NOTIMPL;
389 static HRESULT WINAPI WMPPlayer4_put_fullScreen(IWMPPlayer4 *iface, VARIANT_BOOL fullscreen)
391 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
392 FIXME("(%p)->(%x)\n", This, fullscreen);
393 return E_NOTIMPL;
396 static HRESULT WINAPI WMPPlayer4_get_enableContextMenu(IWMPPlayer4 *iface, VARIANT_BOOL *pbEnableContextMenu)
398 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
399 FIXME("(%p)->(%p)\n", This, pbEnableContextMenu);
400 return E_NOTIMPL;
403 static HRESULT WINAPI WMPPlayer4_put_enableContextMenu(IWMPPlayer4 *iface, VARIANT_BOOL enable)
405 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
406 FIXME("(%p)->(%x)\n", This, enable);
407 return E_NOTIMPL;
410 static HRESULT WINAPI WMPPlayer4_put_uiMode(IWMPPlayer4 *iface, BSTR mode)
412 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
413 FIXME("(%p)->(%s)\n", This, debugstr_w(mode));
414 return E_NOTIMPL;
417 static HRESULT WINAPI WMPPlayer4_get_uiMode(IWMPPlayer4 *iface, BSTR *pbstrMode)
419 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
420 FIXME("(%p)->(%p)\n", This, pbstrMode);
421 return E_NOTIMPL;
424 static HRESULT WINAPI WMPPlayer4_get_stretchToFit(IWMPPlayer4 *iface, VARIANT_BOOL *enabled)
426 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
427 FIXME("(%p)->(%p)\n", This, enabled);
428 return E_NOTIMPL;
431 static HRESULT WINAPI WMPPlayer4_put_stretchToFit(IWMPPlayer4 *iface, VARIANT_BOOL enabled)
433 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
434 FIXME("(%p)->(%x)\n", This, enabled);
435 return E_NOTIMPL;
438 static HRESULT WINAPI WMPPlayer4_get_windowlessVideo(IWMPPlayer4 *iface, VARIANT_BOOL *enabled)
440 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
441 FIXME("(%p)->(%p)\n", This, enabled);
442 return E_NOTIMPL;
445 static HRESULT WINAPI WMPPlayer4_put_windowlessVideo(IWMPPlayer4 *iface, VARIANT_BOOL enabled)
447 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
448 FIXME("(%p)->(%x)\n", This, enabled);
449 return E_NOTIMPL;
452 static HRESULT WINAPI WMPPlayer4_get_isRemote(IWMPPlayer4 *iface, VARIANT_BOOL *pvarfIsRemote)
454 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
455 FIXME("(%p)->(%p)\n", This, pvarfIsRemote);
456 return E_NOTIMPL;
459 static HRESULT WINAPI WMPPlayer4_get_playerApplication(IWMPPlayer4 *iface, IWMPPlayerApplication **ppIWMPPlayerApplication)
461 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
462 FIXME("(%p)->(%p)\n", This, ppIWMPPlayerApplication);
463 return E_NOTIMPL;
466 static HRESULT WINAPI WMPPlayer4_openPlayer(IWMPPlayer4 *iface, BSTR url)
468 WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
469 FIXME("(%p)->(%s)\n", This, debugstr_w(url));
470 return E_NOTIMPL;
473 static HRESULT WINAPI WMPPlayer_QueryInterface(IWMPPlayer *iface, REFIID riid, void **ppv)
475 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
476 return WMPPlayer4_QueryInterface(&This->IWMPPlayer4_iface, riid, ppv);
479 static ULONG WINAPI WMPPlayer_AddRef(IWMPPlayer *iface)
481 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
482 return WMPPlayer4_AddRef(&This->IWMPPlayer4_iface);
485 static ULONG WINAPI WMPPlayer_Release(IWMPPlayer *iface)
487 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
488 return WMPPlayer4_Release(&This->IWMPPlayer4_iface);
491 static HRESULT WINAPI WMPPlayer_GetTypeInfoCount(IWMPPlayer *iface, UINT *pctinfo)
493 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
494 return WMPPlayer4_GetTypeInfoCount(&This->IWMPPlayer4_iface, pctinfo);
497 static HRESULT WINAPI WMPPlayer_GetTypeInfo(IWMPPlayer *iface, UINT iTInfo,
498 LCID lcid, ITypeInfo **ppTInfo)
500 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
502 return WMPPlayer4_GetTypeInfo(&This->IWMPPlayer4_iface, iTInfo,
503 lcid, ppTInfo);
506 static HRESULT WINAPI WMPPlayer_GetIDsOfNames(IWMPPlayer *iface, REFIID riid,
507 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
509 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
510 return WMPPlayer4_GetIDsOfNames(&This->IWMPPlayer4_iface, riid,
511 rgszNames, cNames, lcid, rgDispId);
514 static HRESULT WINAPI WMPPlayer_Invoke(IWMPPlayer *iface, DISPID dispIdMember,
515 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
516 EXCEPINFO *pExcepInfo, UINT *puArgErr)
518 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
519 return WMPPlayer4_Invoke(&This->IWMPPlayer4_iface, dispIdMember,
520 riid, lcid, wFlags, pDispParams, pVarResult,
521 pExcepInfo, puArgErr);
524 static HRESULT WINAPI WMPPlayer_close(IWMPPlayer *iface)
526 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
527 return WMPPlayer4_close(&This->IWMPPlayer4_iface);
530 static HRESULT WINAPI WMPPlayer_get_URL(IWMPPlayer *iface, BSTR *pbstrURL)
532 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
533 return WMPPlayer4_get_URL(&This->IWMPPlayer4_iface, pbstrURL);
536 static HRESULT WINAPI WMPPlayer_put_URL(IWMPPlayer *iface, BSTR url)
538 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
539 return WMPPlayer4_put_URL(&This->IWMPPlayer4_iface, url);
542 static HRESULT WINAPI WMPPlayer_get_openState(IWMPPlayer *iface, WMPOpenState *pwmpos)
544 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
545 return WMPPlayer4_get_openState(&This->IWMPPlayer4_iface, pwmpos);
548 static HRESULT WINAPI WMPPlayer_get_playState(IWMPPlayer *iface, WMPPlayState *pwmpps)
550 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
551 return WMPPlayer4_get_playState(&This->IWMPPlayer4_iface, pwmpps);
554 static HRESULT WINAPI WMPPlayer_get_controls(IWMPPlayer *iface, IWMPControls **ppControl)
556 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
557 return WMPPlayer4_get_controls(&This->IWMPPlayer4_iface, ppControl);
560 static HRESULT WINAPI WMPPlayer_get_settings(IWMPPlayer *iface, IWMPSettings **ppSettings)
562 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
563 return WMPPlayer4_get_settings(&This->IWMPPlayer4_iface, ppSettings);
566 static HRESULT WINAPI WMPPlayer_get_currentMedia(IWMPPlayer *iface, IWMPMedia **ppMedia)
568 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
569 return WMPPlayer4_get_currentMedia(&This->IWMPPlayer4_iface, ppMedia);
572 static HRESULT WINAPI WMPPlayer_put_currentMedia(IWMPPlayer *iface, IWMPMedia *pMedia)
574 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
575 return WMPPlayer4_put_currentMedia(&This->IWMPPlayer4_iface, pMedia);
578 static HRESULT WINAPI WMPPlayer_get_mediaCollection(IWMPPlayer *iface, IWMPMediaCollection **ppMediaCollection)
580 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
581 return WMPPlayer4_get_mediaCollection(&This->IWMPPlayer4_iface, ppMediaCollection);
584 static HRESULT WINAPI WMPPlayer_get_playlistCollection(IWMPPlayer *iface, IWMPPlaylistCollection **ppPlaylistCollection)
586 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
587 return WMPPlayer4_get_playlistCollection(&This->IWMPPlayer4_iface, ppPlaylistCollection);
590 static HRESULT WINAPI WMPPlayer_get_versionInfo(IWMPPlayer *iface, BSTR *version)
592 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
593 return WMPPlayer4_get_versionInfo(&This->IWMPPlayer4_iface, version);
596 static HRESULT WINAPI WMPPlayer_launchURL(IWMPPlayer *iface, BSTR url)
598 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
599 return WMPPlayer4_launchURL(&This->IWMPPlayer4_iface, url);
602 static HRESULT WINAPI WMPPlayer_get_network(IWMPPlayer *iface, IWMPNetwork **ppQNI)
604 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
605 return WMPPlayer4_get_network(&This->IWMPPlayer4_iface, ppQNI);
608 static HRESULT WINAPI WMPPlayer_get_currentPlaylist(IWMPPlayer *iface, IWMPPlaylist **ppPL)
610 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
611 return WMPPlayer4_get_currentPlaylist(&This->IWMPPlayer4_iface, ppPL);
614 static HRESULT WINAPI WMPPlayer_put_currentPlaylist(IWMPPlayer *iface, IWMPPlaylist *pPL)
616 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
617 return WMPPlayer4_put_currentPlaylist(&This->IWMPPlayer4_iface, pPL);
620 static HRESULT WINAPI WMPPlayer_get_cdromCollection(IWMPPlayer *iface, IWMPCdromCollection **ppCdromCollection)
622 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
623 return WMPPlayer4_get_cdromCollection(&This->IWMPPlayer4_iface, ppCdromCollection);
626 static HRESULT WINAPI WMPPlayer_get_closedCaption(IWMPPlayer *iface, IWMPClosedCaption **ppClosedCaption)
628 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
629 return WMPPlayer4_get_closedCaption(&This->IWMPPlayer4_iface, ppClosedCaption);
632 static HRESULT WINAPI WMPPlayer_get_isOnline(IWMPPlayer *iface, VARIANT_BOOL *pfOnline)
634 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
635 return WMPPlayer4_get_isOnline(&This->IWMPPlayer4_iface, pfOnline);
638 static HRESULT WINAPI WMPPlayer_get_Error(IWMPPlayer *iface, IWMPError **ppError)
640 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
641 return WMPPlayer4_get_Error(&This->IWMPPlayer4_iface, ppError);
644 static HRESULT WINAPI WMPPlayer_get_Status(IWMPPlayer *iface, BSTR *pbstrStatus)
646 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
647 return WMPPlayer4_get_Status(&This->IWMPPlayer4_iface, pbstrStatus);
650 static HRESULT WINAPI WMPPlayer_get_enabled(IWMPPlayer *iface, VARIANT_BOOL *pbEnabled)
652 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
653 return WMPPlayer4_get_enabled(&This->IWMPPlayer4_iface, pbEnabled);
656 static HRESULT WINAPI WMPPlayer_put_enabled(IWMPPlayer *iface, VARIANT_BOOL enabled)
658 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
659 return WMPPlayer4_put_enabled(&This->IWMPPlayer4_iface, enabled);
662 static HRESULT WINAPI WMPPlayer_get_fullScreen(IWMPPlayer *iface, VARIANT_BOOL *pbFullScreen)
664 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
665 return WMPPlayer4_get_fullScreen(&This->IWMPPlayer4_iface, pbFullScreen);
668 static HRESULT WINAPI WMPPlayer_put_fullScreen(IWMPPlayer *iface, VARIANT_BOOL fullscreen)
670 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
671 return WMPPlayer4_put_fullScreen(&This->IWMPPlayer4_iface, fullscreen);
674 static HRESULT WINAPI WMPPlayer_get_enableContextMenu(IWMPPlayer *iface, VARIANT_BOOL *pbEnableContextMenu)
676 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
677 return WMPPlayer4_get_enableContextMenu(&This->IWMPPlayer4_iface, pbEnableContextMenu);
680 static HRESULT WINAPI WMPPlayer_put_enableContextMenu(IWMPPlayer *iface, VARIANT_BOOL enable)
682 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
683 return WMPPlayer4_put_enableContextMenu(&This->IWMPPlayer4_iface, enable);
686 static HRESULT WINAPI WMPPlayer_put_uiMode(IWMPPlayer *iface, BSTR mode)
688 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
689 return WMPPlayer4_put_uiMode(&This->IWMPPlayer4_iface, mode);
692 static HRESULT WINAPI WMPPlayer_get_uiMode(IWMPPlayer *iface, BSTR *pbstrMode)
694 WindowsMediaPlayer *This = impl_from_IWMPPlayer(iface);
695 return WMPPlayer4_get_uiMode(&This->IWMPPlayer4_iface, pbstrMode);
698 static IWMPPlayerVtbl WMPPlayerVtbl = {
699 WMPPlayer_QueryInterface,
700 WMPPlayer_AddRef,
701 WMPPlayer_Release,
702 WMPPlayer_GetTypeInfoCount,
703 WMPPlayer_GetTypeInfo,
704 WMPPlayer_GetIDsOfNames,
705 WMPPlayer_Invoke,
706 WMPPlayer_close,
707 WMPPlayer_get_URL,
708 WMPPlayer_put_URL,
709 WMPPlayer_get_openState,
710 WMPPlayer_get_playState,
711 WMPPlayer_get_controls,
712 WMPPlayer_get_settings,
713 WMPPlayer_get_currentMedia,
714 WMPPlayer_put_currentMedia,
715 WMPPlayer_get_mediaCollection,
716 WMPPlayer_get_playlistCollection,
717 WMPPlayer_get_versionInfo,
718 WMPPlayer_launchURL,
719 WMPPlayer_get_network,
720 WMPPlayer_get_currentPlaylist,
721 WMPPlayer_put_currentPlaylist,
722 WMPPlayer_get_cdromCollection,
723 WMPPlayer_get_closedCaption,
724 WMPPlayer_get_isOnline,
725 WMPPlayer_get_Error,
726 WMPPlayer_get_Status,
727 WMPPlayer_get_enabled,
728 WMPPlayer_put_enabled,
729 WMPPlayer_get_fullScreen,
730 WMPPlayer_put_fullScreen,
731 WMPPlayer_get_enableContextMenu,
732 WMPPlayer_put_enableContextMenu,
733 WMPPlayer_put_uiMode,
734 WMPPlayer_get_uiMode,
738 static IWMPPlayer4Vtbl WMPPlayer4Vtbl = {
739 WMPPlayer4_QueryInterface,
740 WMPPlayer4_AddRef,
741 WMPPlayer4_Release,
742 WMPPlayer4_GetTypeInfoCount,
743 WMPPlayer4_GetTypeInfo,
744 WMPPlayer4_GetIDsOfNames,
745 WMPPlayer4_Invoke,
746 WMPPlayer4_close,
747 WMPPlayer4_get_URL,
748 WMPPlayer4_put_URL,
749 WMPPlayer4_get_openState,
750 WMPPlayer4_get_playState,
751 WMPPlayer4_get_controls,
752 WMPPlayer4_get_settings,
753 WMPPlayer4_get_currentMedia,
754 WMPPlayer4_put_currentMedia,
755 WMPPlayer4_get_mediaCollection,
756 WMPPlayer4_get_playlistCollection,
757 WMPPlayer4_get_versionInfo,
758 WMPPlayer4_launchURL,
759 WMPPlayer4_get_network,
760 WMPPlayer4_get_currentPlaylist,
761 WMPPlayer4_put_currentPlaylist,
762 WMPPlayer4_get_cdromCollection,
763 WMPPlayer4_get_closedCaption,
764 WMPPlayer4_get_isOnline,
765 WMPPlayer4_get_Error,
766 WMPPlayer4_get_Status,
767 WMPPlayer4_get_dvd,
768 WMPPlayer4_newPlaylist,
769 WMPPlayer4_newMedia,
770 WMPPlayer4_get_enabled,
771 WMPPlayer4_put_enabled,
772 WMPPlayer4_get_fullScreen,
773 WMPPlayer4_put_fullScreen,
774 WMPPlayer4_get_enableContextMenu,
775 WMPPlayer4_put_enableContextMenu,
776 WMPPlayer4_put_uiMode,
777 WMPPlayer4_get_uiMode,
778 WMPPlayer4_get_stretchToFit,
779 WMPPlayer4_put_stretchToFit,
780 WMPPlayer4_get_windowlessVideo,
781 WMPPlayer4_put_windowlessVideo,
782 WMPPlayer4_get_isRemote,
783 WMPPlayer4_get_playerApplication,
784 WMPPlayer4_openPlayer
787 static inline WindowsMediaPlayer *impl_from_IWMPSettings(IWMPSettings *iface)
789 return CONTAINING_RECORD(iface, WindowsMediaPlayer, IWMPSettings_iface);
792 static HRESULT WINAPI WMPSettings_QueryInterface(IWMPSettings *iface, REFIID riid, void **ppv)
794 WindowsMediaPlayer *This = impl_from_IWMPSettings(iface);
795 return IOleObject_QueryInterface(&This->IOleObject_iface, riid, ppv);
798 static ULONG WINAPI WMPSettings_AddRef(IWMPSettings *iface)
800 WindowsMediaPlayer *This = impl_from_IWMPSettings(iface);
801 return IOleObject_AddRef(&This->IOleObject_iface);
804 static ULONG WINAPI WMPSettings_Release(IWMPSettings *iface)
806 WindowsMediaPlayer *This = impl_from_IWMPSettings(iface);
807 return IOleObject_Release(&This->IOleObject_iface);
810 static HRESULT WINAPI WMPSettings_GetTypeInfoCount(IWMPSettings *iface, UINT *pctinfo)
812 WindowsMediaPlayer *This = impl_from_IWMPSettings(iface);
813 FIXME("(%p)->(%p)\n", This, pctinfo);
814 return E_NOTIMPL;
817 static HRESULT WINAPI WMPSettings_GetTypeInfo(IWMPSettings *iface, UINT iTInfo,
818 LCID lcid, ITypeInfo **ppTInfo)
820 WindowsMediaPlayer *This = impl_from_IWMPSettings(iface);
821 FIXME("(%p)->(%u %d %p)\n", This, iTInfo, lcid, ppTInfo);
822 return E_NOTIMPL;
825 static HRESULT WINAPI WMPSettings_GetIDsOfNames(IWMPSettings *iface, REFIID riid,
826 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
828 WindowsMediaPlayer *This = impl_from_IWMPSettings(iface);
829 FIXME("(%p)->(%s %p %u %d %p)\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
830 return E_NOTIMPL;
833 static HRESULT WINAPI WMPSettings_Invoke(IWMPSettings *iface, DISPID dispIdMember,
834 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
835 EXCEPINFO *pExcepInfo, UINT *puArgErr)
837 WindowsMediaPlayer *This = impl_from_IWMPSettings(iface);
838 FIXME("(%p)->(%d %s %d %x %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid), lcid,
839 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
840 return E_NOTIMPL;
843 static HRESULT WINAPI WMPSettings_get_isAvailable(IWMPSettings *iface, BSTR item, VARIANT_BOOL *p)
845 WindowsMediaPlayer *This = impl_from_IWMPSettings(iface);
846 FIXME("(%p)->(%s %p)\n", This, debugstr_w(item), p);
847 return E_NOTIMPL;
850 static HRESULT WINAPI WMPSettings_get_autoStart(IWMPSettings *iface, VARIANT_BOOL *p)
852 WindowsMediaPlayer *This = impl_from_IWMPSettings(iface);
853 TRACE("(%p)->(%p)\n", This, p);
854 if (!p)
855 return E_POINTER;
856 *p = This->auto_start;
857 return S_OK;
860 static HRESULT WINAPI WMPSettings_put_autoStart(IWMPSettings *iface, VARIANT_BOOL v)
862 WindowsMediaPlayer *This = impl_from_IWMPSettings(iface);
863 TRACE("(%p)->(%x)\n", This, v);
864 This->auto_start = v;
865 return S_OK;
868 static HRESULT WINAPI WMPSettings_get_baseURL(IWMPSettings *iface, BSTR *p)
870 WindowsMediaPlayer *This = impl_from_IWMPSettings(iface);
871 FIXME("(%p)->(%p)\n", This, p);
872 return E_NOTIMPL;
875 static HRESULT WINAPI WMPSettings_put_baseURL(IWMPSettings *iface, BSTR v)
877 WindowsMediaPlayer *This = impl_from_IWMPSettings(iface);
878 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
879 return E_NOTIMPL;
882 static HRESULT WINAPI WMPSettings_get_defaultFrame(IWMPSettings *iface, BSTR *p)
884 WindowsMediaPlayer *This = impl_from_IWMPSettings(iface);
885 FIXME("(%p)->(%p)\n", This, p);
886 return E_NOTIMPL;
889 static HRESULT WINAPI WMPSettings_put_defaultFrame(IWMPSettings *iface, BSTR v)
891 WindowsMediaPlayer *This = impl_from_IWMPSettings(iface);
892 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
893 return E_NOTIMPL;
896 static HRESULT WINAPI WMPSettings_get_invokeURLs(IWMPSettings *iface, VARIANT_BOOL *p)
898 WindowsMediaPlayer *This = impl_from_IWMPSettings(iface);
900 TRACE("(%p)->(%p)\n", This, p);
902 if (!p)
903 return E_POINTER;
904 *p = This->invoke_urls;
905 return S_OK;
908 static HRESULT WINAPI WMPSettings_put_invokeURLs(IWMPSettings *iface, VARIANT_BOOL v)
910 WindowsMediaPlayer *This = impl_from_IWMPSettings(iface);
911 /* Leaving as FIXME as we don't currently use this */
912 FIXME("(%p)->(%x)\n", This, v);
913 This->invoke_urls = v;
914 return S_OK;
917 static HRESULT WINAPI WMPSettings_get_mute(IWMPSettings *iface, VARIANT_BOOL *p)
919 WindowsMediaPlayer *This = impl_from_IWMPSettings(iface);
920 FIXME("(%p)->(%p)\n", This, p);
921 return E_NOTIMPL;
924 static HRESULT WINAPI WMPSettings_put_mute(IWMPSettings *iface, VARIANT_BOOL v)
926 WindowsMediaPlayer *This = impl_from_IWMPSettings(iface);
927 FIXME("(%p)->(%x)\n", This, v);
928 return E_NOTIMPL;
931 static HRESULT WINAPI WMPSettings_get_playCount(IWMPSettings *iface, LONG *p)
933 WindowsMediaPlayer *This = impl_from_IWMPSettings(iface);
934 FIXME("(%p)->(%p)\n", This, p);
935 return E_NOTIMPL;
938 static HRESULT WINAPI WMPSettings_put_playCount(IWMPSettings *iface, LONG v)
940 WindowsMediaPlayer *This = impl_from_IWMPSettings(iface);
941 FIXME("(%p)->(%d)\n", This, v);
942 return E_NOTIMPL;
945 static HRESULT WINAPI WMPSettings_get_rate(IWMPSettings *iface, double *p)
947 WindowsMediaPlayer *This = impl_from_IWMPSettings(iface);
948 FIXME("(%p)->(%p)\n", This, p);
949 return E_NOTIMPL;
952 static HRESULT WINAPI WMPSettings_put_rate(IWMPSettings *iface, double v)
954 WindowsMediaPlayer *This = impl_from_IWMPSettings(iface);
955 FIXME("(%p)->(%lf)\n", This, v);
956 return E_NOTIMPL;
959 static HRESULT WINAPI WMPSettings_get_balance(IWMPSettings *iface, LONG *p)
961 WindowsMediaPlayer *This = impl_from_IWMPSettings(iface);
962 FIXME("(%p)->(%p)\n", This, p);
963 return E_NOTIMPL;
966 static HRESULT WINAPI WMPSettings_put_balance(IWMPSettings *iface, LONG v)
968 WindowsMediaPlayer *This = impl_from_IWMPSettings(iface);
969 FIXME("(%p)->(%d)\n", This, v);
970 return E_NOTIMPL;
973 static HRESULT WINAPI WMPSettings_get_volume(IWMPSettings *iface, LONG *p)
975 WindowsMediaPlayer *This = impl_from_IWMPSettings(iface);
976 TRACE("(%p)->(%p)\n", This, p);
977 if (!p)
978 return E_POINTER;
979 *p = This->volume;
980 return S_OK;
983 static HRESULT WINAPI WMPSettings_put_volume(IWMPSettings *iface, LONG v)
985 WindowsMediaPlayer *This = impl_from_IWMPSettings(iface);
986 TRACE("(%p)->(%d)\n", This, v);
987 This->volume = v;
988 if (!This->filter_graph)
989 return S_OK;
991 /* IBasicAudio - [-10000, 0], wmp - [0, 100] */
992 v = 10000 * v / 100 - 10000;
993 if (!This->basic_audio)
994 return S_FALSE;
996 return IBasicAudio_put_Volume(This->basic_audio, v);
999 static HRESULT WINAPI WMPSettings_getMode(IWMPSettings *iface, BSTR mode, VARIANT_BOOL *p)
1001 WindowsMediaPlayer *This = impl_from_IWMPSettings(iface);
1002 FIXME("(%p)->(%s %p)\n", This, debugstr_w(mode), p);
1003 return E_NOTIMPL;
1006 static HRESULT WINAPI WMPSettings_setMode(IWMPSettings *iface, BSTR mode, VARIANT_BOOL v)
1008 WindowsMediaPlayer *This = impl_from_IWMPSettings(iface);
1009 FIXME("(%p)->(%s %x)\n", This, debugstr_w(mode), v);
1010 return E_NOTIMPL;
1013 static HRESULT WINAPI WMPSettings_get_enableErrorDialogs(IWMPSettings *iface, VARIANT_BOOL *p)
1015 WindowsMediaPlayer *This = impl_from_IWMPSettings(iface);
1017 TRACE("(%p)->(%p)\n", This, p);
1019 if (!p)
1020 return E_POINTER;
1021 *p = This->enable_error_dialogs;
1022 return S_OK;
1025 static HRESULT WINAPI WMPSettings_put_enableErrorDialogs(IWMPSettings *iface, VARIANT_BOOL v)
1027 WindowsMediaPlayer *This = impl_from_IWMPSettings(iface);
1028 /* Leaving as FIXME as we don't currently use this */
1029 FIXME("(%p)->(%x)\n", This, v);
1030 This->enable_error_dialogs = v;
1031 return S_OK;
1034 static const IWMPSettingsVtbl WMPSettingsVtbl = {
1035 WMPSettings_QueryInterface,
1036 WMPSettings_AddRef,
1037 WMPSettings_Release,
1038 WMPSettings_GetTypeInfoCount,
1039 WMPSettings_GetTypeInfo,
1040 WMPSettings_GetIDsOfNames,
1041 WMPSettings_Invoke,
1042 WMPSettings_get_isAvailable,
1043 WMPSettings_get_autoStart,
1044 WMPSettings_put_autoStart,
1045 WMPSettings_get_baseURL,
1046 WMPSettings_put_baseURL,
1047 WMPSettings_get_defaultFrame,
1048 WMPSettings_put_defaultFrame,
1049 WMPSettings_get_invokeURLs,
1050 WMPSettings_put_invokeURLs,
1051 WMPSettings_get_mute,
1052 WMPSettings_put_mute,
1053 WMPSettings_get_playCount,
1054 WMPSettings_put_playCount,
1055 WMPSettings_get_rate,
1056 WMPSettings_put_rate,
1057 WMPSettings_get_balance,
1058 WMPSettings_put_balance,
1059 WMPSettings_get_volume,
1060 WMPSettings_put_volume,
1061 WMPSettings_getMode,
1062 WMPSettings_setMode,
1063 WMPSettings_get_enableErrorDialogs,
1064 WMPSettings_put_enableErrorDialogs
1067 static HRESULT WINAPI WMPNetwork_QueryInterface(IWMPNetwork *iface, REFIID riid, void **ppv)
1069 if(IsEqualGUID(riid, &IID_IDispatch)) {
1070 *ppv = iface;
1071 }else if(IsEqualGUID(riid, &IID_IWMPNetwork)) {
1072 *ppv = iface;
1073 }else {
1074 WARN("Unsupported interface (%s)\n", wine_dbgstr_guid(riid));
1075 *ppv = NULL;
1076 return E_NOINTERFACE;
1079 IUnknown_AddRef((IUnknown*)*ppv);
1080 return S_OK;
1083 static ULONG WINAPI WMPNetwork_AddRef(IWMPNetwork *iface)
1085 WindowsMediaPlayer *This = impl_from_IWMPNetwork(iface);
1086 return IOleObject_AddRef(&This->IOleObject_iface);
1089 static ULONG WINAPI WMPNetwork_Release(IWMPNetwork *iface)
1091 WindowsMediaPlayer *This = impl_from_IWMPNetwork(iface);
1092 return IOleObject_Release(&This->IOleObject_iface);
1095 static HRESULT WINAPI WMPNetwork_GetTypeInfoCount(IWMPNetwork *iface, UINT *pctinfo)
1097 WindowsMediaPlayer *This = impl_from_IWMPNetwork(iface);
1098 FIXME("(%p)->(%p)\n", This, pctinfo);
1099 return E_NOTIMPL;
1102 static HRESULT WINAPI WMPNetwork_GetTypeInfo(IWMPNetwork *iface, UINT iTInfo,
1103 LCID lcid, ITypeInfo **ppTInfo)
1105 WindowsMediaPlayer *This = impl_from_IWMPNetwork(iface);
1106 FIXME("(%p)->(%u %d %p)\n", This, iTInfo, lcid, ppTInfo);
1107 return E_NOTIMPL;
1110 static HRESULT WINAPI WMPNetwork_GetIDsOfNames(IWMPNetwork *iface, REFIID riid,
1111 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
1113 WindowsMediaPlayer *This = impl_from_IWMPNetwork(iface);
1114 FIXME("(%p)->(%s %p %u %d %p)\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
1115 return E_NOTIMPL;
1118 static HRESULT WINAPI WMPNetwork_Invoke(IWMPNetwork *iface, DISPID dispIdMember,
1119 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
1120 EXCEPINFO *pExcepInfo, UINT *puArgErr)
1122 WindowsMediaPlayer *This = impl_from_IWMPNetwork(iface);
1123 FIXME("(%p)->(%d %s %d %x %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid), lcid,
1124 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1125 return E_NOTIMPL;
1128 static HRESULT WINAPI WMPNetwork_get_bandWidth(IWMPNetwork *iface, LONG *plBandwidth)
1130 WindowsMediaPlayer *This = impl_from_IWMPNetwork(iface);
1131 FIXME("(%p)->(%p)\n", This, plBandwidth);
1132 return E_NOTIMPL;
1135 static HRESULT WINAPI WMPNetwork_get_recoveredPackets(IWMPNetwork *iface, LONG *plRecoveredPackets)
1137 WindowsMediaPlayer *This = impl_from_IWMPNetwork(iface);
1138 FIXME("(%p)->(%p)\n", This, plRecoveredPackets);
1139 return E_NOTIMPL;
1142 static HRESULT WINAPI WMPNetwork_get_sourceProtocol(IWMPNetwork *iface, BSTR *pbstrSourceProtocol)
1144 WindowsMediaPlayer *This = impl_from_IWMPNetwork(iface);
1145 FIXME("(%p)->(%p)\n", This, pbstrSourceProtocol);
1146 return E_NOTIMPL;
1149 static HRESULT WINAPI WMPNetwork_get_receivedPackets(IWMPNetwork *iface, LONG *plReceivedPackets)
1151 WindowsMediaPlayer *This = impl_from_IWMPNetwork(iface);
1152 FIXME("(%p)->(%p)\n", This, plReceivedPackets);
1153 return E_NOTIMPL;
1156 static HRESULT WINAPI WMPNetwork_get_lostPackets(IWMPNetwork *iface, LONG *plLostPackets)
1158 WindowsMediaPlayer *This = impl_from_IWMPNetwork(iface);
1159 FIXME("(%p)->(%p)\n", This, plLostPackets);
1160 return E_NOTIMPL;
1163 static HRESULT WINAPI WMPNetwork_get_receptionQuality(IWMPNetwork *iface, LONG *plReceptionQuality)
1165 WindowsMediaPlayer *This = impl_from_IWMPNetwork(iface);
1166 FIXME("(%p)->(%p)\n", This, plReceptionQuality);
1167 return E_NOTIMPL;
1170 static HRESULT WINAPI WMPNetwork_get_bufferingCount(IWMPNetwork *iface, LONG *plBufferingCount)
1172 WindowsMediaPlayer *This = impl_from_IWMPNetwork(iface);
1173 FIXME("(%p)->(%p)\n", This, plBufferingCount);
1174 return E_NOTIMPL;
1177 static HRESULT WINAPI WMPNetwork_get_bufferingProgress(IWMPNetwork *iface, LONG *plBufferingProgress)
1179 WindowsMediaPlayer *This = impl_from_IWMPNetwork(iface);
1180 TRACE("(%p)->(%p)\n", This, plBufferingProgress);
1181 if (!This->filter_graph) {
1182 return S_FALSE;
1184 /* Ideally we would use IAMOpenProgress for URL reader but we don't have it in wine (yet)
1185 * For file sources FileAsyncReader->Length should work
1186 * */
1187 FIXME("stub: Returning buffering progress 100\n");
1188 *plBufferingProgress = 100;
1190 return S_OK;
1193 static HRESULT WINAPI WMPNetwork_get_bufferingTime(IWMPNetwork *iface, LONG *plBufferingTime)
1195 WindowsMediaPlayer *This = impl_from_IWMPNetwork(iface);
1196 FIXME("(%p)->(%p)\n", This, plBufferingTime);
1197 return E_NOTIMPL;
1200 static HRESULT WINAPI WMPNetwork_put_bufferingTime(IWMPNetwork *iface, LONG lBufferingTime)
1202 WindowsMediaPlayer *This = impl_from_IWMPNetwork(iface);
1203 FIXME("(%p)->(%d)\n", This, lBufferingTime);
1204 return E_NOTIMPL;
1207 static HRESULT WINAPI WMPNetwork_get_frameRate(IWMPNetwork *iface, LONG *plFrameRate)
1209 WindowsMediaPlayer *This = impl_from_IWMPNetwork(iface);
1210 FIXME("(%p)->(%p)\n", This, plFrameRate);
1211 return E_NOTIMPL;
1214 static HRESULT WINAPI WMPNetwork_get_maxBitRate(IWMPNetwork *iface, LONG *plBitRate)
1216 WindowsMediaPlayer *This = impl_from_IWMPNetwork(iface);
1217 FIXME("(%p)->(%p)\n", This, plBitRate);
1218 return E_NOTIMPL;
1221 static HRESULT WINAPI WMPNetwork_get_bitRate(IWMPNetwork *iface, LONG *plBitRate)
1223 WindowsMediaPlayer *This = impl_from_IWMPNetwork(iface);
1224 FIXME("(%p)->(%p)\n", This, plBitRate);
1225 return E_NOTIMPL;
1228 static HRESULT WINAPI WMPNetwork_getProxySettings(IWMPNetwork *iface, BSTR bstrProtocol, LONG *plProxySetting)
1230 WindowsMediaPlayer *This = impl_from_IWMPNetwork(iface);
1231 FIXME("(%p)->(%s, %p)\n", This, debugstr_w(bstrProtocol), plProxySetting);
1232 return E_NOTIMPL;
1235 static HRESULT WINAPI WMPNetwork_setProxySettings(IWMPNetwork *iface, BSTR bstrProtocol, LONG lProxySetting)
1237 WindowsMediaPlayer *This = impl_from_IWMPNetwork(iface);
1238 FIXME("(%p)->(%s, %d)\n", This, debugstr_w(bstrProtocol), lProxySetting);
1239 return E_NOTIMPL;
1242 static HRESULT WINAPI WMPNetwork_getProxyName(IWMPNetwork *iface, BSTR bstrProtocol, BSTR *pbstrProxyName)
1244 WindowsMediaPlayer *This = impl_from_IWMPNetwork(iface);
1245 FIXME("(%p)->(%s, %p)\n", This, debugstr_w(bstrProtocol), pbstrProxyName);
1246 return E_NOTIMPL;
1249 static HRESULT WINAPI WMPNetwork_setProxyName(IWMPNetwork *iface, BSTR bstrProtocol, BSTR bstrProxyName)
1251 WindowsMediaPlayer *This = impl_from_IWMPNetwork(iface);
1252 FIXME("(%p)->(%s, %s)\n", This, debugstr_w(bstrProtocol), debugstr_w(bstrProxyName));
1253 return E_NOTIMPL;
1256 static HRESULT WINAPI WMPNetwork_getProxyPort(IWMPNetwork *iface, BSTR bstrProtocol, LONG *plProxyPort)
1258 WindowsMediaPlayer *This = impl_from_IWMPNetwork(iface);
1259 FIXME("(%p)->(%s, %p)\n", This, debugstr_w(bstrProtocol), plProxyPort);
1260 return E_NOTIMPL;
1263 static HRESULT WINAPI WMPNetwork_setProxyPort(IWMPNetwork *iface, BSTR bstrProtocol, LONG lProxyPort)
1265 WindowsMediaPlayer *This = impl_from_IWMPNetwork(iface);
1266 FIXME("(%p)->(%s, %d)\n", This, debugstr_w(bstrProtocol), lProxyPort);
1267 return E_NOTIMPL;
1270 static HRESULT WINAPI WMPNetwork_getProxyExceptionList(IWMPNetwork *iface, BSTR bstrProtocol, BSTR *pbstrExceptionList)
1272 WindowsMediaPlayer *This = impl_from_IWMPNetwork(iface);
1273 FIXME("(%p)->(%s, %p)\n", This, debugstr_w(bstrProtocol), pbstrExceptionList);
1274 return E_NOTIMPL;
1277 static HRESULT WINAPI WMPNetwork_setProxyExceptionList(IWMPNetwork *iface, BSTR bstrProtocol, BSTR bstrExceptionList)
1279 WindowsMediaPlayer *This = impl_from_IWMPNetwork(iface);
1280 FIXME("(%p)->(%s, %s)\n", This, debugstr_w(bstrProtocol), debugstr_w(bstrExceptionList));
1281 return E_NOTIMPL;
1284 static HRESULT WINAPI WMPNetwork_getProxyBypassForLocal(IWMPNetwork *iface, BSTR bstrProtocol, VARIANT_BOOL *pfBypassForLocal)
1286 WindowsMediaPlayer *This = impl_from_IWMPNetwork(iface);
1287 FIXME("(%p)->(%s, %p)\n", This, debugstr_w(bstrProtocol), pfBypassForLocal);
1288 return E_NOTIMPL;
1291 static HRESULT WINAPI WMPNetwork_setProxyBypassForLocal(IWMPNetwork *iface, BSTR bstrProtocol, VARIANT_BOOL fBypassForLocal)
1293 WindowsMediaPlayer *This = impl_from_IWMPNetwork(iface);
1294 FIXME("(%p)->(%s, %d)\n", This, debugstr_w(bstrProtocol), fBypassForLocal);
1295 return E_NOTIMPL;
1298 static HRESULT WINAPI WMPNetwork_get_maxBandwidth(IWMPNetwork *iface, LONG *plMaxBandwidth)
1300 WindowsMediaPlayer *This = impl_from_IWMPNetwork(iface);
1301 FIXME("(%p)->(%p)\n", This, plMaxBandwidth);
1302 return E_NOTIMPL;
1305 static HRESULT WINAPI WMPNetwork_put_maxBandwidth(IWMPNetwork *iface, LONG lMaxBandwidth)
1307 WindowsMediaPlayer *This = impl_from_IWMPNetwork(iface);
1308 FIXME("(%p)->(%d)\n", This, lMaxBandwidth);
1309 return E_NOTIMPL;
1312 static HRESULT WINAPI WMPNetwork_get_downloadProgress(IWMPNetwork *iface, LONG *plDownloadProgress)
1314 WindowsMediaPlayer *This = impl_from_IWMPNetwork(iface);
1315 TRACE("(%p)->(%p)\n", This, plDownloadProgress);
1316 if (!This->filter_graph) {
1317 return S_FALSE;
1319 /* Ideally we would use IAMOpenProgress for URL reader but we don't have it in wine (yet)
1320 * For file sources FileAsyncReader->Length could work or it should just be
1321 * 100
1322 * */
1323 FIXME("stub: Returning download progress 100\n");
1324 *plDownloadProgress = 100;
1326 return S_OK;
1329 static HRESULT WINAPI WMPNetwork_get_encodedFrameRate(IWMPNetwork *iface, LONG *plFrameRate)
1331 WindowsMediaPlayer *This = impl_from_IWMPNetwork(iface);
1332 FIXME("(%p)->(%p)\n", This, plFrameRate);
1333 return E_NOTIMPL;
1336 static HRESULT WINAPI WMPNetwork_get_framesSkipped(IWMPNetwork *iface, LONG *plFrames)
1338 WindowsMediaPlayer *This = impl_from_IWMPNetwork(iface);
1339 FIXME("(%p)->(%p)\n", This, plFrames);
1340 return E_NOTIMPL;
1343 static const IWMPNetworkVtbl WMPNetworkVtbl = {
1344 WMPNetwork_QueryInterface,
1345 WMPNetwork_AddRef,
1346 WMPNetwork_Release,
1347 WMPNetwork_GetTypeInfoCount,
1348 WMPNetwork_GetTypeInfo,
1349 WMPNetwork_GetIDsOfNames,
1350 WMPNetwork_Invoke,
1351 WMPNetwork_get_bandWidth,
1352 WMPNetwork_get_recoveredPackets,
1353 WMPNetwork_get_sourceProtocol,
1354 WMPNetwork_get_receivedPackets,
1355 WMPNetwork_get_lostPackets,
1356 WMPNetwork_get_receptionQuality,
1357 WMPNetwork_get_bufferingCount,
1358 WMPNetwork_get_bufferingProgress,
1359 WMPNetwork_get_bufferingTime,
1360 WMPNetwork_put_bufferingTime,
1361 WMPNetwork_get_frameRate,
1362 WMPNetwork_get_maxBitRate,
1363 WMPNetwork_get_bitRate,
1364 WMPNetwork_getProxySettings,
1365 WMPNetwork_setProxySettings,
1366 WMPNetwork_getProxyName,
1367 WMPNetwork_setProxyName,
1368 WMPNetwork_getProxyPort,
1369 WMPNetwork_setProxyPort,
1370 WMPNetwork_getProxyExceptionList,
1371 WMPNetwork_setProxyExceptionList,
1372 WMPNetwork_getProxyBypassForLocal,
1373 WMPNetwork_setProxyBypassForLocal,
1374 WMPNetwork_get_maxBandwidth,
1375 WMPNetwork_put_maxBandwidth,
1376 WMPNetwork_get_downloadProgress,
1377 WMPNetwork_get_encodedFrameRate,
1378 WMPNetwork_get_framesSkipped,
1381 static HRESULT WINAPI WMPControls_QueryInterface(IWMPControls *iface, REFIID riid, void **ppv)
1383 if(IsEqualGUID(riid, &IID_IUnknown)) {
1384 *ppv = iface;
1385 }else if(IsEqualGUID(riid, &IID_IDispatch)) {
1386 *ppv = iface;
1387 }else if(IsEqualGUID(riid, &IID_IWMPControls)) {
1388 *ppv = iface;
1389 }else {
1390 WARN("Unsupported interface (%s)\n", wine_dbgstr_guid(riid));
1391 *ppv = NULL;
1392 return E_NOINTERFACE;
1395 IUnknown_AddRef((IUnknown*)*ppv);
1396 return S_OK;
1399 static ULONG WINAPI WMPControls_AddRef(IWMPControls *iface)
1401 WindowsMediaPlayer *This = impl_from_IWMPControls(iface);
1402 return IOleObject_AddRef(&This->IOleObject_iface);
1405 static ULONG WINAPI WMPControls_Release(IWMPControls *iface)
1407 WindowsMediaPlayer *This = impl_from_IWMPControls(iface);
1408 return IOleObject_Release(&This->IOleObject_iface);
1411 static HRESULT WINAPI WMPControls_GetTypeInfoCount(IWMPControls *iface, UINT *pctinfo)
1413 WindowsMediaPlayer *This = impl_from_IWMPControls(iface);
1414 FIXME("(%p)->(%p)\n", This, pctinfo);
1415 return E_NOTIMPL;
1418 static HRESULT WINAPI WMPControls_GetTypeInfo(IWMPControls *iface, UINT iTInfo,
1419 LCID lcid, ITypeInfo **ppTInfo)
1421 WindowsMediaPlayer *This = impl_from_IWMPControls(iface);
1422 FIXME("(%p)->(%u %d %p)\n", This, iTInfo, lcid, ppTInfo);
1423 return E_NOTIMPL;
1426 static HRESULT WINAPI WMPControls_GetIDsOfNames(IWMPControls *iface, REFIID riid,
1427 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
1429 WindowsMediaPlayer *This = impl_from_IWMPControls(iface);
1430 FIXME("(%p)->(%s %p %u %d %p)\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
1431 return E_NOTIMPL;
1434 static HRESULT WINAPI WMPControls_Invoke(IWMPControls *iface, DISPID dispIdMember,
1435 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
1436 EXCEPINFO *pExcepInfo, UINT *puArgErr)
1438 WindowsMediaPlayer *This = impl_from_IWMPControls(iface);
1439 FIXME("(%p)->(%d %s %d %x %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid), lcid,
1440 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1441 return E_NOTIMPL;
1444 static HRESULT WINAPI WMPControls_get_isAvailable(IWMPControls *iface, BSTR bstrItem, VARIANT_BOOL *pIsAvailable)
1446 WindowsMediaPlayer *This = impl_from_IWMPControls(iface);
1447 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrItem), pIsAvailable);
1448 if (!This->filter_graph) {
1449 *pIsAvailable = VARIANT_FALSE;
1450 } else if (wcscmp(L"currentPosition", bstrItem) == 0) {
1451 DWORD capabilities;
1452 IMediaSeeking_GetCapabilities(This->media_seeking, &capabilities);
1453 *pIsAvailable = (capabilities & AM_SEEKING_CanSeekAbsolute) ?
1454 VARIANT_TRUE : VARIANT_FALSE;
1455 } else {
1456 FIXME("%s not implemented\n", debugstr_w(bstrItem));
1457 return E_NOTIMPL;
1460 return S_OK;
1463 static HRESULT WINAPI WMPControls_play(IWMPControls *iface)
1465 HRESULT hres = S_OK;
1466 WindowsMediaPlayer *This = impl_from_IWMPControls(iface);
1468 TRACE("(%p)\n", This);
1470 if (!This->media) {
1471 return NS_S_WMPCORE_COMMAND_NOT_AVAILABLE;
1474 if (!This->filter_graph) {
1475 hres = CoCreateInstance(&CLSID_FilterGraph,
1476 NULL,
1477 CLSCTX_INPROC_SERVER,
1478 &IID_IGraphBuilder,
1479 (void **)&This->filter_graph);
1480 update_state(This, DISPID_WMPCOREEVENT_OPENSTATECHANGE, wmposOpeningUnknownURL);
1482 if (SUCCEEDED(hres))
1483 hres = IGraphBuilder_RenderFile(This->filter_graph, This->media->url, NULL);
1484 if (SUCCEEDED(hres))
1485 update_state(This, DISPID_WMPCOREEVENT_OPENSTATECHANGE, wmposMediaOpen);
1486 if (SUCCEEDED(hres))
1487 hres = IGraphBuilder_QueryInterface(This->filter_graph, &IID_IMediaControl,
1488 (void**)&This->media_control);
1489 if (SUCCEEDED(hres))
1490 hres = IGraphBuilder_QueryInterface(This->filter_graph, &IID_IMediaSeeking,
1491 (void**)&This->media_seeking);
1492 if (SUCCEEDED(hres))
1493 hres = IMediaSeeking_SetTimeFormat(This->media_seeking, &TIME_FORMAT_MEDIA_TIME);
1494 if (SUCCEEDED(hres))
1495 hres = IGraphBuilder_QueryInterface(This->filter_graph, &IID_IMediaEvent,
1496 (void**)&This->media_event);
1497 if (SUCCEEDED(hres))
1499 IMediaEventEx *media_event_ex = NULL;
1500 hres = IGraphBuilder_QueryInterface(This->filter_graph, &IID_IMediaEventEx,
1501 (void**)&media_event_ex);
1502 if (SUCCEEDED(hres)) {
1503 hres = IMediaEventEx_SetNotifyWindow(media_event_ex, (OAHWND)This->msg_window,
1504 WM_WMPEVENT, (LONG_PTR)This);
1505 IMediaEventEx_Release(media_event_ex);
1508 if (SUCCEEDED(hres))
1509 hres = IGraphBuilder_QueryInterface(This->filter_graph, &IID_IBasicAudio, (void**)&This->basic_audio);
1510 if (SUCCEEDED(hres))
1511 hres = IWMPSettings_put_volume(&This->IWMPSettings_iface, This->volume);
1514 update_state(This, DISPID_WMPCOREEVENT_PLAYSTATECHANGE, wmppsTransitioning);
1516 if (SUCCEEDED(hres))
1517 hres = IMediaControl_Run(This->media_control);
1519 if (hres == S_FALSE) {
1520 hres = S_OK; /* S_FALSE will mean that graph is transitioning and that is fine */
1523 if (SUCCEEDED(hres)) {
1524 LONGLONG duration;
1525 update_state(This, DISPID_WMPCOREEVENT_PLAYSTATECHANGE, wmppsPlaying);
1526 if (SUCCEEDED(IMediaSeeking_GetDuration(This->media_seeking, &duration)))
1527 This->media->duration = (DOUBLE)duration / 10000000.0f;
1528 } else {
1529 update_state(This, DISPID_WMPCOREEVENT_PLAYSTATECHANGE, wmppsUndefined);
1532 return hres;
1535 static HRESULT WINAPI WMPControls_stop(IWMPControls *iface)
1537 HRESULT hres = S_OK;
1538 WindowsMediaPlayer *This = impl_from_IWMPControls(iface);
1539 TRACE("(%p)\n", This);
1540 if (!This->filter_graph) {
1541 return NS_S_WMPCORE_COMMAND_NOT_AVAILABLE;
1543 if (This->media_control) {
1544 hres = IMediaControl_Stop(This->media_control);
1545 IMediaControl_Release(This->media_control);
1547 if (This->media_event) {
1548 IMediaEvent_Release(This->media_event);
1550 if (This->media_seeking) {
1551 IMediaSeeking_Release(This->media_seeking);
1553 if (This->basic_audio) {
1554 IBasicAudio_Release(This->basic_audio);
1556 IGraphBuilder_Release(This->filter_graph);
1557 This->filter_graph = NULL;
1558 This->media_control = NULL;
1559 This->media_event = NULL;
1560 This->media_seeking = NULL;
1561 This->basic_audio = NULL;
1563 update_state(This, DISPID_WMPCOREEVENT_OPENSTATECHANGE, wmposPlaylistOpenNoMedia);
1564 update_state(This, DISPID_WMPCOREEVENT_PLAYSTATECHANGE, wmppsStopped);
1565 return hres;
1568 static HRESULT WINAPI WMPControls_pause(IWMPControls *iface)
1570 WindowsMediaPlayer *This = impl_from_IWMPControls(iface);
1571 FIXME("(%p)\n", This);
1572 return E_NOTIMPL;
1575 static HRESULT WINAPI WMPControls_fastForward(IWMPControls *iface)
1577 WindowsMediaPlayer *This = impl_from_IWMPControls(iface);
1578 FIXME("(%p)\n", This);
1579 return E_NOTIMPL;
1582 static HRESULT WINAPI WMPControls_fastReverse(IWMPControls *iface)
1584 WindowsMediaPlayer *This = impl_from_IWMPControls(iface);
1585 FIXME("(%p)\n", This);
1586 return E_NOTIMPL;
1589 static HRESULT WINAPI WMPControls_get_currentPosition(IWMPControls *iface, DOUBLE *pdCurrentPosition)
1591 WindowsMediaPlayer *This = impl_from_IWMPControls(iface);
1592 HRESULT hres;
1593 LONGLONG currentPosition;
1595 TRACE("(%p)->(%p)\n", This, pdCurrentPosition);
1596 if (!This->media_seeking)
1597 return S_FALSE;
1599 hres = IMediaSeeking_GetCurrentPosition(This->media_seeking, &currentPosition);
1600 *pdCurrentPosition = (DOUBLE) currentPosition / 10000000.0f;
1601 TRACE("hres: %d, pos: %f\n", hres, *pdCurrentPosition);
1602 return hres;
1605 static HRESULT WINAPI WMPControls_put_currentPosition(IWMPControls *iface, DOUBLE dCurrentPosition)
1607 LONGLONG Current;
1608 HRESULT hres;
1609 WindowsMediaPlayer *This = impl_from_IWMPControls(iface);
1610 TRACE("(%p)->(%f)\n", This, dCurrentPosition);
1611 if (!This->media_seeking)
1612 return S_FALSE;
1614 Current = 10000000 * dCurrentPosition;
1615 hres = IMediaSeeking_SetPositions(This->media_seeking, &Current,
1616 AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
1618 return hres;
1621 static HRESULT WINAPI WMPControls_get_currentPositionString(IWMPControls *iface, BSTR *pbstrCurrentPosition)
1623 WindowsMediaPlayer *This = impl_from_IWMPControls(iface);
1624 FIXME("(%p)->(%p)\n", This, pbstrCurrentPosition);
1625 return E_NOTIMPL;
1628 static HRESULT WINAPI WMPControls_next(IWMPControls *iface)
1630 WindowsMediaPlayer *This = impl_from_IWMPControls(iface);
1631 FIXME("(%p)\n", This);
1632 return E_NOTIMPL;
1635 static HRESULT WINAPI WMPControls_previous(IWMPControls *iface)
1637 WindowsMediaPlayer *This = impl_from_IWMPControls(iface);
1638 FIXME("(%p)\n", This);
1639 return E_NOTIMPL;
1642 static HRESULT WINAPI WMPControls_get_currentItem(IWMPControls *iface, IWMPMedia **ppIWMPMedia)
1644 WindowsMediaPlayer *This = impl_from_IWMPControls(iface);
1645 FIXME("(%p)->(%p)\n", This, ppIWMPMedia);
1646 return E_NOTIMPL;
1649 static HRESULT WINAPI WMPControls_put_currentItem(IWMPControls *iface, IWMPMedia *pIWMPMedia)
1651 WindowsMediaPlayer *This = impl_from_IWMPControls(iface);
1652 FIXME("(%p)->(%p)\n", This, pIWMPMedia);
1653 return E_NOTIMPL;
1656 static HRESULT WINAPI WMPControls_get_currentMarker(IWMPControls *iface, LONG *plMarker)
1658 WindowsMediaPlayer *This = impl_from_IWMPControls(iface);
1659 FIXME("(%p)->(%p)\n", This, plMarker);
1660 return E_NOTIMPL;
1663 static HRESULT WINAPI WMPControls_put_currentMarker(IWMPControls *iface, LONG lMarker)
1665 WindowsMediaPlayer *This = impl_from_IWMPControls(iface);
1666 FIXME("(%p)->(%d)\n", This, lMarker);
1667 return E_NOTIMPL;
1670 static HRESULT WINAPI WMPControls_playItem(IWMPControls *iface, IWMPMedia *pIWMPMedia)
1672 WindowsMediaPlayer *This = impl_from_IWMPControls(iface);
1673 FIXME("(%p)->(%p)\n", This, pIWMPMedia);
1674 return E_NOTIMPL;
1677 static const IWMPControlsVtbl WMPControlsVtbl = {
1678 WMPControls_QueryInterface,
1679 WMPControls_AddRef,
1680 WMPControls_Release,
1681 WMPControls_GetTypeInfoCount,
1682 WMPControls_GetTypeInfo,
1683 WMPControls_GetIDsOfNames,
1684 WMPControls_Invoke,
1685 WMPControls_get_isAvailable,
1686 WMPControls_play,
1687 WMPControls_stop,
1688 WMPControls_pause,
1689 WMPControls_fastForward,
1690 WMPControls_fastReverse,
1691 WMPControls_get_currentPosition,
1692 WMPControls_put_currentPosition,
1693 WMPControls_get_currentPositionString,
1694 WMPControls_next,
1695 WMPControls_previous,
1696 WMPControls_get_currentItem,
1697 WMPControls_put_currentItem,
1698 WMPControls_get_currentMarker,
1699 WMPControls_put_currentMarker,
1700 WMPControls_playItem,
1703 static HRESULT WINAPI WMPMedia_QueryInterface(IWMPMedia *iface, REFIID riid, void **ppv)
1705 WMPMedia *This = impl_from_IWMPMedia(iface);
1706 TRACE("(%p)\n", This);
1707 if(IsEqualGUID(&IID_IUnknown, riid)) {
1708 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1709 *ppv = &This->IWMPMedia_iface;
1710 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
1711 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
1712 *ppv = &This->IWMPMedia_iface;
1713 }else if(IsEqualGUID(&IID_IWMPMedia, riid)) {
1714 TRACE("(%p)->(IID_IWMPMedia %p)\n", This, ppv);
1715 *ppv = &This->IWMPMedia_iface;
1716 }else {
1717 WARN("Unsupported interface %s\n", debugstr_guid(riid));
1718 *ppv = NULL;
1719 return E_NOINTERFACE;
1722 IUnknown_AddRef((IUnknown*)*ppv);
1723 return S_OK;
1726 static ULONG WINAPI WMPMedia_AddRef(IWMPMedia *iface)
1728 WMPMedia *This = impl_from_IWMPMedia(iface);
1729 LONG ref = InterlockedIncrement(&This->ref);
1731 TRACE("(%p) ref=%d\n", This, ref);
1733 return ref;
1736 static ULONG WINAPI WMPMedia_Release(IWMPMedia *iface)
1738 WMPMedia *This = impl_from_IWMPMedia(iface);
1739 LONG ref = InterlockedDecrement(&This->ref);
1741 TRACE("(%p) ref=%d\n", This, ref);
1743 if(!ref) {
1744 heap_free(This->url);
1745 heap_free(This->name);
1746 heap_free(This);
1749 return ref;
1752 static HRESULT WINAPI WMPMedia_GetTypeInfoCount(IWMPMedia *iface, UINT *pctinfo)
1754 WMPMedia *This = impl_from_IWMPMedia(iface);
1755 FIXME("(%p)->(%p)\n", This, pctinfo);
1756 return E_NOTIMPL;
1759 static HRESULT WINAPI WMPMedia_GetTypeInfo(IWMPMedia *iface, UINT iTInfo,
1760 LCID lcid, ITypeInfo **ppTInfo)
1762 WMPMedia *This = impl_from_IWMPMedia(iface);
1763 FIXME("(%p)->(%u %d %p)\n", This, iTInfo, lcid, ppTInfo);
1764 return E_NOTIMPL;
1767 static HRESULT WINAPI WMPMedia_GetIDsOfNames(IWMPMedia *iface, REFIID riid,
1768 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
1770 WMPMedia *This = impl_from_IWMPMedia(iface);
1771 FIXME("(%p)->(%s %p %u %d %p)\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
1772 return E_NOTIMPL;
1775 static HRESULT WINAPI WMPMedia_Invoke(IWMPMedia *iface, DISPID dispIdMember,
1776 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
1777 EXCEPINFO *pExcepInfo, UINT *puArgErr)
1779 WMPMedia *This = impl_from_IWMPMedia(iface);
1780 FIXME("(%p)->(%d %s %d %x %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid), lcid,
1781 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1782 return E_NOTIMPL;
1785 static HRESULT WINAPI WMPMedia_get_isIdentical(IWMPMedia *iface, IWMPMedia *other, VARIANT_BOOL *pvBool)
1787 WMPMedia *This = impl_from_IWMPMedia(iface);
1788 FIXME("(%p)->(%p, %p)\n", This, other, pvBool);
1789 return E_NOTIMPL;
1792 static HRESULT WINAPI WMPMedia_get_sourceURL(IWMPMedia *iface, BSTR *url)
1794 WMPMedia *This = impl_from_IWMPMedia(iface);
1796 TRACE("(%p)->(%p)\n", This, url);
1798 return return_bstr(This->url, url);
1801 static HRESULT WINAPI WMPMedia_get_name(IWMPMedia *iface, BSTR *name)
1803 WMPMedia *This = impl_from_IWMPMedia(iface);
1805 TRACE("(%p)->(%p)\n", This, name);
1807 return return_bstr(This->name, name);
1810 static HRESULT WINAPI WMPMedia_put_name(IWMPMedia *iface, BSTR name)
1812 WMPMedia *This = impl_from_IWMPMedia(iface);
1814 TRACE("(%p)->(%s)\n", This, debugstr_w(name));
1816 if (!name) return E_POINTER;
1818 heap_free(This->name);
1819 This->name = heap_strdupW(name);
1820 return S_OK;
1823 static HRESULT WINAPI WMPMedia_get_imageSourceWidth(IWMPMedia *iface, LONG *pWidth)
1825 WMPMedia *This = impl_from_IWMPMedia(iface);
1826 FIXME("(%p)->(%p)\n", This, pWidth);
1827 return E_NOTIMPL;
1830 static HRESULT WINAPI WMPMedia_get_imageSourceHeight(IWMPMedia *iface, LONG *pHeight)
1832 WMPMedia *This = impl_from_IWMPMedia(iface);
1833 FIXME("(%p)->(%p)\n", This, pHeight);
1834 return E_NOTIMPL;
1837 static HRESULT WINAPI WMPMedia_get_markerCount(IWMPMedia *iface, LONG* pMarkerCount)
1839 WMPMedia *This = impl_from_IWMPMedia(iface);
1840 FIXME("(%p)->(%p)\n", This, pMarkerCount);
1841 return E_NOTIMPL;
1844 static HRESULT WINAPI WMPMedia_getMarkerTime(IWMPMedia *iface, LONG MarkerNum, DOUBLE *pMarkerTime)
1846 WMPMedia *This = impl_from_IWMPMedia(iface);
1847 FIXME("(%p)->(%d, %p)\n", This, MarkerNum, pMarkerTime);
1848 return E_NOTIMPL;
1851 static HRESULT WINAPI WMPMedia_getMarkerName(IWMPMedia *iface, LONG MarkerNum, BSTR *pbstrMarkerName)
1853 WMPMedia *This = impl_from_IWMPMedia(iface);
1854 FIXME("(%p)->(%d, %p)\n", This, MarkerNum, pbstrMarkerName);
1855 return E_NOTIMPL;
1858 static HRESULT WINAPI WMPMedia_get_duration(IWMPMedia *iface, DOUBLE *pDuration)
1860 /* MSDN: If this property is used with a media item other than the one
1861 * specified in Player.currentMedia, it may not contain a valid value. */
1862 WMPMedia *This = impl_from_IWMPMedia(iface);
1863 TRACE("(%p)->(%p)\n", This, pDuration);
1864 *pDuration = This->duration;
1865 return S_OK;
1868 static HRESULT WINAPI WMPMedia_get_durationString(IWMPMedia *iface, BSTR *pbstrDuration)
1870 WMPMedia *This = impl_from_IWMPMedia(iface);
1871 FIXME("(%p)->(%p)\n", This, pbstrDuration);
1872 return E_NOTIMPL;
1875 static HRESULT WINAPI WMPMedia_get_attributeCount(IWMPMedia *iface, LONG *plCount)
1877 WMPMedia *This = impl_from_IWMPMedia(iface);
1878 FIXME("(%p)->(%p)\n", This, plCount);
1879 return E_NOTIMPL;
1882 static HRESULT WINAPI WMPMedia_getAttributeName(IWMPMedia *iface, LONG lIndex, BSTR *pbstrItemName)
1884 WMPMedia *This = impl_from_IWMPMedia(iface);
1885 FIXME("(%p)->(%d, %p)\n", This, lIndex, pbstrItemName);
1886 return E_NOTIMPL;
1889 static HRESULT WINAPI WMPMedia_getItemInfo(IWMPMedia *iface, BSTR item_name, BSTR *value)
1891 WMPMedia *This = impl_from_IWMPMedia(iface);
1892 FIXME("(%p)->(%s, %p)\n", This, debugstr_w(item_name), value);
1893 return return_bstr(NULL, value);
1896 static HRESULT WINAPI WMPMedia_setItemInfo(IWMPMedia *iface, BSTR bstrItemName, BSTR bstrVal)
1898 WMPMedia *This = impl_from_IWMPMedia(iface);
1899 FIXME("(%p)->(%s, %s)\n", This, debugstr_w(bstrItemName), debugstr_w(bstrVal));
1900 return E_NOTIMPL;
1903 static HRESULT WINAPI WMPMedia_getItemInfoByAtom(IWMPMedia *iface, LONG lAtom, BSTR *pbstrVal)
1905 WMPMedia *This = impl_from_IWMPMedia(iface);
1906 FIXME("(%p)->(%d, %p)\n", This, lAtom, pbstrVal);
1907 return E_NOTIMPL;
1910 static HRESULT WINAPI WMPMedia_isMemberOf(IWMPMedia *iface, IWMPPlaylist *pPlaylist, VARIANT_BOOL *pvarfIsMemberOf)
1912 WMPMedia *This = impl_from_IWMPMedia(iface);
1913 FIXME("(%p)->(%p, %p)\n", This, pPlaylist, pvarfIsMemberOf);
1914 return E_NOTIMPL;
1917 static HRESULT WINAPI WMPMedia_isReadOnlyItem(IWMPMedia *iface, BSTR bstrItemName, VARIANT_BOOL *pvarfIsReadOnly)
1919 WMPMedia *This = impl_from_IWMPMedia(iface);
1920 FIXME("(%p)->(%s, %p)\n", This, debugstr_w(bstrItemName), pvarfIsReadOnly);
1921 return E_NOTIMPL;
1924 static const IWMPMediaVtbl WMPMediaVtbl = {
1925 WMPMedia_QueryInterface,
1926 WMPMedia_AddRef,
1927 WMPMedia_Release,
1928 WMPMedia_GetTypeInfoCount,
1929 WMPMedia_GetTypeInfo,
1930 WMPMedia_GetIDsOfNames,
1931 WMPMedia_Invoke,
1932 WMPMedia_get_isIdentical,
1933 WMPMedia_get_sourceURL,
1934 WMPMedia_get_name,
1935 WMPMedia_put_name,
1936 WMPMedia_get_imageSourceWidth,
1937 WMPMedia_get_imageSourceHeight,
1938 WMPMedia_get_markerCount,
1939 WMPMedia_getMarkerTime,
1940 WMPMedia_getMarkerName,
1941 WMPMedia_get_duration,
1942 WMPMedia_get_durationString,
1943 WMPMedia_get_attributeCount,
1944 WMPMedia_getAttributeName,
1945 WMPMedia_getItemInfo,
1946 WMPMedia_setItemInfo,
1947 WMPMedia_getItemInfoByAtom,
1948 WMPMedia_isMemberOf,
1949 WMPMedia_isReadOnlyItem
1952 static HRESULT WINAPI WMPPlaylist_QueryInterface(IWMPPlaylist *iface, REFIID riid, void **ppv)
1954 WMPPlaylist *This = impl_from_IWMPPlaylist(iface);
1955 TRACE("(%p)\n", This);
1956 if(IsEqualGUID(&IID_IUnknown, riid)) {
1957 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1958 *ppv = &This->IWMPPlaylist_iface;
1959 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
1960 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
1961 *ppv = &This->IWMPPlaylist_iface;
1962 }else if(IsEqualGUID(&IID_IWMPPlaylist, riid)) {
1963 TRACE("(%p)->(IID_IWMPPlaylist %p)\n", This, ppv);
1964 *ppv = &This->IWMPPlaylist_iface;
1965 }else {
1966 WARN("Unsupported interface %s\n", debugstr_guid(riid));
1967 *ppv = NULL;
1968 return E_NOINTERFACE;
1971 IUnknown_AddRef((IUnknown*)*ppv);
1972 return S_OK;
1975 static ULONG WINAPI WMPPlaylist_AddRef(IWMPPlaylist *iface)
1977 WMPPlaylist *This = impl_from_IWMPPlaylist(iface);
1978 LONG ref = InterlockedIncrement(&This->ref);
1980 TRACE("(%p) ref=%d\n", This, ref);
1982 return ref;
1985 static ULONG WINAPI WMPPlaylist_Release(IWMPPlaylist *iface)
1987 WMPPlaylist *This = impl_from_IWMPPlaylist(iface);
1988 LONG ref = InterlockedDecrement(&This->ref);
1990 TRACE("(%p) ref=%d\n", This, ref);
1992 if(!ref) {
1993 heap_free(This->url);
1994 heap_free(This->name);
1995 heap_free(This);
1998 return ref;
2001 static HRESULT WINAPI WMPPlaylist_GetTypeInfoCount(IWMPPlaylist *iface, UINT *pctinfo)
2003 WMPPlaylist *This = impl_from_IWMPPlaylist(iface);
2004 FIXME("(%p)->(%p)\n", This, pctinfo);
2005 return E_NOTIMPL;
2008 static HRESULT WINAPI WMPPlaylist_GetTypeInfo(IWMPPlaylist *iface, UINT iTInfo,
2009 LCID lcid, ITypeInfo **ppTInfo)
2011 WMPPlaylist *This = impl_from_IWMPPlaylist(iface);
2012 FIXME("(%p)->(%u %d %p)\n", This, iTInfo, lcid, ppTInfo);
2013 return E_NOTIMPL;
2016 static HRESULT WINAPI WMPPlaylist_GetIDsOfNames(IWMPPlaylist *iface, REFIID riid,
2017 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
2019 WMPPlaylist *This = impl_from_IWMPPlaylist(iface);
2020 FIXME("(%p)->(%s %p %u %d %p)\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
2021 return E_NOTIMPL;
2024 static HRESULT WINAPI WMPPlaylist_Invoke(IWMPPlaylist *iface, DISPID dispIdMember,
2025 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
2026 EXCEPINFO *pExcepInfo, UINT *puArgErr)
2028 WMPPlaylist *This = impl_from_IWMPPlaylist(iface);
2029 FIXME("(%p)->(%d %s %d %x %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid), lcid,
2030 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2031 return E_NOTIMPL;
2034 static HRESULT WINAPI WMPPlaylist_get_count(IWMPPlaylist *iface, LONG *count)
2036 WMPPlaylist *This = impl_from_IWMPPlaylist(iface);
2038 TRACE("(%p)->(%p)\n", This, count);
2040 if (!count) return E_POINTER;
2041 *count = This->count;
2043 return S_OK;
2046 static HRESULT WINAPI WMPPlaylist_get_name(IWMPPlaylist *iface, BSTR *name)
2048 WMPPlaylist *This = impl_from_IWMPPlaylist(iface);
2050 TRACE("(%p)->(%p)\n", This, name);
2052 return return_bstr(This->name, name);
2055 static HRESULT WINAPI WMPPlaylist_put_name(IWMPPlaylist *iface, BSTR name)
2057 WMPPlaylist *This = impl_from_IWMPPlaylist(iface);
2059 TRACE("(%p)->(%s)\n", This, debugstr_w(name));
2061 if (!name) return E_POINTER;
2063 heap_free(This->name);
2064 This->name = heap_strdupW(name);
2065 return S_OK;
2068 static HRESULT WINAPI WMPPlaylist_get_attributeCount(IWMPPlaylist *iface, LONG *count)
2070 WMPPlaylist *This = impl_from_IWMPPlaylist(iface);
2071 FIXME("(%p)->(%p)\n", This, count);
2072 return E_NOTIMPL;
2075 static HRESULT WINAPI WMPPlaylist_get_attributeName(IWMPPlaylist *iface, LONG index, BSTR *attribute_name)
2077 WMPPlaylist *This = impl_from_IWMPPlaylist(iface);
2078 FIXME("(%p)->(%d %p)\n", This, index, attribute_name);
2079 return E_NOTIMPL;
2082 static HRESULT WINAPI WMPPlaylist_get_Item(IWMPPlaylist *iface, LONG index, IWMPMedia **media)
2084 WMPPlaylist *This = impl_from_IWMPPlaylist(iface);
2085 FIXME("(%p)->(%d %p)\n", This, index, media);
2086 return E_NOTIMPL;
2089 static HRESULT WINAPI WMPPlaylist_getItemInfo(IWMPPlaylist *iface, BSTR name, BSTR *value)
2091 WMPPlaylist *This = impl_from_IWMPPlaylist(iface);
2092 FIXME("(%p)->(%s %p)\n", This, debugstr_w(name), value);
2093 return E_NOTIMPL;
2096 static HRESULT WINAPI WMPPlaylist_setItemInfo(IWMPPlaylist *iface, BSTR name, BSTR value)
2098 WMPPlaylist *This = impl_from_IWMPPlaylist(iface);
2099 FIXME("(%p)->(%s %s)\n", This, debugstr_w(name), debugstr_w(value));
2100 return E_NOTIMPL;
2103 static HRESULT WINAPI WMPPlaylist_get_isIdentical(IWMPPlaylist *iface, IWMPPlaylist *playlist, VARIANT_BOOL *var)
2105 WMPPlaylist *This = impl_from_IWMPPlaylist(iface);
2106 FIXME("(%p)->(%p %p)\n", This, playlist, var);
2107 return E_NOTIMPL;
2110 static HRESULT WINAPI WMPPlaylist_clear(IWMPPlaylist *iface)
2112 WMPPlaylist *This = impl_from_IWMPPlaylist(iface);
2113 FIXME("(%p)\n", This);
2114 return E_NOTIMPL;
2117 static HRESULT WINAPI WMPPlaylist_insertItem(IWMPPlaylist *iface, LONG index, IWMPMedia *media)
2119 WMPPlaylist *This = impl_from_IWMPPlaylist(iface);
2120 FIXME("(%p)->(%d %p)\n", This, index, media);
2121 return E_NOTIMPL;
2124 static HRESULT WINAPI WMPPlaylist_appendItem(IWMPPlaylist *iface, IWMPMedia *media)
2126 WMPPlaylist *This = impl_from_IWMPPlaylist(iface);
2127 FIXME("(%p)->(%p)\n", This, media);
2128 return S_OK;
2131 static HRESULT WINAPI WMPPlaylist_removeItem(IWMPPlaylist *iface, IWMPMedia *media)
2133 WMPPlaylist *This = impl_from_IWMPPlaylist(iface);
2134 FIXME("(%p)->(%p)\n", This, media);
2135 return E_NOTIMPL;
2138 static HRESULT WINAPI WMPPlaylist_moveItem(IWMPPlaylist *iface, LONG old_index, LONG new_index)
2140 WMPPlaylist *This = impl_from_IWMPPlaylist(iface);
2141 FIXME("(%p)->(%d %d)\n", This, old_index, new_index);
2142 return E_NOTIMPL;
2145 static const IWMPPlaylistVtbl WMPPlaylistVtbl = {
2146 WMPPlaylist_QueryInterface,
2147 WMPPlaylist_AddRef,
2148 WMPPlaylist_Release,
2149 WMPPlaylist_GetTypeInfoCount,
2150 WMPPlaylist_GetTypeInfo,
2151 WMPPlaylist_GetIDsOfNames,
2152 WMPPlaylist_Invoke,
2153 WMPPlaylist_get_count,
2154 WMPPlaylist_get_name,
2155 WMPPlaylist_put_name,
2156 WMPPlaylist_get_attributeCount,
2157 WMPPlaylist_get_attributeName,
2158 WMPPlaylist_get_Item,
2159 WMPPlaylist_getItemInfo,
2160 WMPPlaylist_setItemInfo,
2161 WMPPlaylist_get_isIdentical,
2162 WMPPlaylist_clear,
2163 WMPPlaylist_insertItem,
2164 WMPPlaylist_appendItem,
2165 WMPPlaylist_removeItem,
2166 WMPPlaylist_moveItem
2169 static LRESULT WINAPI player_wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
2171 if (msg == WM_WMPEVENT && wParam == 0) {
2172 WindowsMediaPlayer *wmp = (WindowsMediaPlayer*)lParam;
2173 LONG event_code;
2174 LONG_PTR p1, p2;
2175 HRESULT hr;
2176 if (wmp->media_event) {
2177 do {
2178 hr = IMediaEvent_GetEvent(wmp->media_event, &event_code, &p1, &p2, 0);
2179 if (SUCCEEDED(hr)) {
2180 TRACE("got event_code = 0x%02x\n", event_code);
2181 IMediaEvent_FreeEventParams(wmp->media_event, event_code, p1, p2);
2182 /* For now we only handle EC_COMPLETE */
2183 if (event_code == EC_COMPLETE) {
2184 update_state(wmp, DISPID_WMPCOREEVENT_PLAYSTATECHANGE, wmppsMediaEnded);
2185 update_state(wmp, DISPID_WMPCOREEVENT_PLAYSTATECHANGE, wmppsTransitioning);
2186 update_state(wmp, DISPID_WMPCOREEVENT_PLAYSTATECHANGE, wmppsStopped);
2189 } while (hr == S_OK);
2190 } else {
2191 FIXME("Got event from quartz when interfaces are already released\n");
2194 return DefWindowProcW(hwnd, msg, wParam, lParam);
2197 static BOOL WINAPI register_player_msg_class(INIT_ONCE *once, void *param, void **context) {
2198 static WNDCLASSEXW wndclass = {
2199 sizeof(wndclass), CS_DBLCLKS, player_wnd_proc, 0, 0,
2200 NULL, NULL, NULL, NULL, NULL,
2201 L"_WMPMessage", NULL
2204 wndclass.hInstance = wmp_instance;
2205 player_msg_class = RegisterClassExW(&wndclass);
2206 WM_WMPEVENT= RegisterWindowMessageW(L"_WMPMessage");
2207 return TRUE;
2210 void unregister_player_msg_class(void) {
2211 if(player_msg_class)
2212 UnregisterClassW(MAKEINTRESOURCEW(player_msg_class), wmp_instance);
2215 BOOL init_player(WindowsMediaPlayer *wmp)
2217 IWMPPlaylist *playlist;
2218 BSTR name;
2220 InitOnceExecuteOnce(&class_init_once, register_player_msg_class, NULL, NULL);
2221 wmp->msg_window = CreateWindowW( MAKEINTRESOURCEW(player_msg_class), NULL, 0, 0,
2222 0, 0, 0, HWND_MESSAGE, 0, wmp_instance, wmp );
2223 if (!wmp->msg_window) {
2224 ERR("Failed to create message window, GetLastError: %d\n", GetLastError());
2225 return FALSE;
2227 if (!WM_WMPEVENT) {
2228 ERR("Failed to register window message, GetLastError: %d\n", GetLastError());
2229 return FALSE;
2232 wmp->IWMPPlayer4_iface.lpVtbl = &WMPPlayer4Vtbl;
2233 wmp->IWMPPlayer_iface.lpVtbl = &WMPPlayerVtbl;
2234 wmp->IWMPSettings_iface.lpVtbl = &WMPSettingsVtbl;
2235 wmp->IWMPControls_iface.lpVtbl = &WMPControlsVtbl;
2236 wmp->IWMPNetwork_iface.lpVtbl = &WMPNetworkVtbl;
2238 name = SysAllocString(L"Playlist1");
2239 if (SUCCEEDED(create_playlist(name, NULL, 0, &playlist)))
2240 wmp->playlist = unsafe_impl_from_IWMPPlaylist(playlist);
2241 else
2242 wmp->playlist = NULL;
2243 SysFreeString(name);
2245 wmp->invoke_urls = VARIANT_TRUE;
2246 wmp->auto_start = VARIANT_TRUE;
2247 wmp->volume = 100;
2248 return TRUE;
2251 void destroy_player(WindowsMediaPlayer *wmp)
2253 IWMPControls_stop(&wmp->IWMPControls_iface);
2254 if (wmp->media)
2255 IWMPMedia_Release(&wmp->media->IWMPMedia_iface);
2256 if (wmp->playlist)
2257 IWMPPlaylist_Release(&wmp->playlist->IWMPPlaylist_iface);
2258 DestroyWindow(wmp->msg_window);
2261 WMPMedia *unsafe_impl_from_IWMPMedia(IWMPMedia *iface)
2263 if (iface->lpVtbl == &WMPMediaVtbl) {
2264 return CONTAINING_RECORD(iface, WMPMedia, IWMPMedia_iface);
2266 return NULL;
2269 WMPPlaylist *unsafe_impl_from_IWMPPlaylist(IWMPPlaylist *iface)
2271 if (iface->lpVtbl == &WMPPlaylistVtbl) {
2272 return CONTAINING_RECORD(iface, WMPPlaylist, IWMPPlaylist_iface);
2274 return NULL;
2277 HRESULT create_media_from_url(BSTR url, double duration, IWMPMedia **ppMedia)
2279 WMPMedia *media;
2280 IUri *uri;
2281 BSTR path;
2282 HRESULT hr;
2283 WCHAR *name_dup;
2285 media = heap_alloc_zero(sizeof(*media));
2286 if (!media)
2287 return E_OUTOFMEMORY;
2289 media->IWMPMedia_iface.lpVtbl = &WMPMediaVtbl;
2291 if (url)
2293 media->url = heap_strdupW(url);
2294 name_dup = heap_strdupW(url);
2296 hr = CreateUri(name_dup, Uri_CREATE_ALLOW_RELATIVE | Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME, 0, &uri);
2297 if (FAILED(hr))
2299 heap_free(name_dup);
2300 IWMPMedia_Release(&media->IWMPMedia_iface);
2301 return hr;
2303 hr = IUri_GetPath(uri, &path);
2304 if (hr != S_OK)
2306 heap_free(name_dup);
2307 IUri_Release(uri);
2308 IWMPMedia_Release(&media->IWMPMedia_iface);
2309 return hr;
2312 /* GetPath() will return "/" for invalid uri's
2313 * only strip extension when uri is valid
2315 if (wcscmp(path, L"/") != 0)
2316 PathRemoveExtensionW(name_dup);
2317 PathStripPathW(name_dup);
2319 media->name = name_dup;
2321 SysFreeString(path);
2322 IUri_Release(uri);
2324 else
2326 media->url = heap_strdupW(L"");
2327 media->name = heap_strdupW(L"");
2330 media->duration = duration;
2331 media->ref = 1;
2333 if (media->url) {
2334 *ppMedia = &media->IWMPMedia_iface;
2336 return S_OK;
2338 IWMPMedia_Release(&media->IWMPMedia_iface);
2339 return E_OUTOFMEMORY;
2342 HRESULT create_playlist(BSTR name, BSTR url, LONG count, IWMPPlaylist **ppPlaylist)
2344 WMPPlaylist *playlist;
2346 playlist = heap_alloc_zero(sizeof(*playlist));
2347 if (!playlist)
2348 return E_OUTOFMEMORY;
2350 playlist->IWMPPlaylist_iface.lpVtbl = &WMPPlaylistVtbl;
2351 playlist->url = heap_strdupW(url ? url : L"");
2352 playlist->name = heap_strdupW(name ? name : L"");
2353 playlist->ref = 1;
2354 playlist->count = count;
2356 if (playlist->url)
2358 *ppPlaylist = &playlist->IWMPPlaylist_iface;
2359 return S_OK;
2362 IWMPPlaylist_Release(&playlist->IWMPPlaylist_iface);
2363 return E_OUTOFMEMORY;