Commit 27338bc4 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

wmp: Improve URL property handling.

parent 54ec72bc
......@@ -28,7 +28,7 @@ static ATOM player_msg_class;
static INIT_ONCE class_init_once;
static UINT WM_WMPEVENT;
static const WCHAR WMPmessageW[] = {'_', 'W', 'M', 'P', 'M','e','s','s','a','g','e',0};
static const WCHAR emptyW[] = {0};
static void update_state(WindowsMediaPlayer *wmp, LONG type, LONG state)
{
......@@ -135,9 +135,8 @@ static HRESULT WINAPI WMPPlayer4_get_URL(IWMPPlayer4 *iface, BSTR *url)
TRACE("(%p)->(%p)\n", This, url);
if(This->media == NULL) {
return S_FALSE;
}
if (!This->media)
return return_bstr(emptyW, url);
return return_bstr(This->media->url, url);
}
......@@ -147,10 +146,8 @@ static HRESULT WINAPI WMPPlayer4_put_URL(IWMPPlayer4 *iface, BSTR url)
WindowsMediaPlayer *This = impl_from_IWMPPlayer4(iface);
IWMPMedia *media;
HRESULT hres;
TRACE("(%p)->(%s)\n", This, debugstr_w(url));
if(url == NULL) {
return E_POINTER;
}
hres = create_media_from_url(url, 0.0, &media);
......@@ -161,9 +158,8 @@ static HRESULT WINAPI WMPPlayer4_put_URL(IWMPPlayer4 *iface, BSTR url)
}
if (SUCCEEDED(hres)) {
update_state(This, DISPID_WMPCOREEVENT_PLAYSTATECHANGE, wmppsReady);
if (This->auto_start == VARIANT_TRUE) {
hres = IWMPControls_play(&This->IWMPControls_iface);
}
if (This->auto_start == VARIANT_TRUE)
IWMPControls_play(&This->IWMPControls_iface);
}
return hres;
......@@ -2025,7 +2021,6 @@ WMPMedia *unsafe_impl_from_IWMPMedia(IWMPMedia *iface)
HRESULT create_media_from_url(BSTR url, double duration, IWMPMedia **ppMedia)
{
static const WCHAR emptyW[] = {0};
WMPMedia *media;
media = heap_alloc_zero(sizeof(*media));
......
......@@ -562,6 +562,54 @@ todo_wine
IWMPPlayer4_Release(player);
}
static void test_player_url(void)
{
IWMPPlayer4 *player;
BSTR str, str2;
HRESULT hr;
hr = CoCreateInstance(&CLSID_WindowsMediaPlayer, NULL, CLSCTX_INPROC_SERVER, &IID_IWMPPlayer4, (void **)&player);
if (hr == REGDB_E_CLASSNOTREG)
{
win_skip("CLSID_WindowsMediaPlayer is not registered.\n");
return;
}
ok(hr == S_OK, "Failed to create media player instance, hr %#x.\n", hr);
hr = IWMPPlayer4_get_URL(player, &str);
ok(hr == S_OK, "Failed to get url, hr %#x.\n", hr);
ok(*str == 0, "Unexpected url %s.\n", wine_dbgstr_w(str));
SysFreeString(str);
str2 = SysAllocString(mp3file);
hr = IWMPPlayer4_put_URL(player, str2);
ok(hr == S_OK, "Failed to set url, hr %#x.\n", hr);
hr = IWMPPlayer4_put_URL(player, NULL);
ok(hr == S_OK, "Failed to set url, hr %#x.\n", hr);
hr = IWMPPlayer4_get_URL(player, &str);
ok(hr == S_OK, "Failed to set url, hr %#x.\n", hr);
ok(*str == 0, "Unexpected url, %s.\n", wine_dbgstr_w(str));
SysFreeString(str);
/* Empty url */
hr = IWMPPlayer4_put_URL(player, str2);
ok(hr == S_OK, "Failed to set url, hr %#x.\n", hr);
str = SysAllocStringLen(NULL, 0);
hr = IWMPPlayer4_put_URL(player, str);
ok(hr == S_OK, "Failed to set url, hr %#x.\n", hr);
SysFreeString(str);
hr = IWMPPlayer4_get_URL(player, &str);
ok(hr == S_OK, "Failed to set url, hr %#x.\n", hr);
ok(*str == 0, "Unexpected url, %s.\n", wine_dbgstr_w(str));
SysFreeString(str);
SysFreeString(str2);
IWMPPlayer4_Release(player);
}
START_TEST(media)
{
CoInitialize(NULL);
......@@ -571,6 +619,7 @@ START_TEST(media)
completed_event = CreateEventW(NULL, FALSE, FALSE, NULL);
test_media_item();
test_player_url();
if (test_wmp()) {
test_completion_event();
} else {
......
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