Strange Behavior with adding to Media Library (WM10) with C
WMPTalk.com Forum Index WMPTalk.com
Discuss Windows Media Player
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web wmptalk.com
Strange Behavior with adding to Media Library (WM10) with C

 
Post new topic   Reply to topic    WMPTalk.com Forum Index -> SDK
Author Message
Scott Ramsay
Guest





Posted: Sat Oct 16, 2004 7:39 am    Post subject: Strange Behavior with adding to Media Library (WM10) with C Reply with quote

Greetings,

I'm attempting to add a single avi to the media library using C++.
Everything runs ok without error. However after my program finishes
executing, the added media does not show up in the Window Media Player
Library.

Am I missing some important call? Some sort of flush call? Does "Add"
requires some minimum item setting e.g. IWMPMedia::setItemInfo

Notes:
- Stepping through with the debugger: all calls return successfully (S_OK)
- The avi is in the media collection of my program if I enumerate after the
add (only during program instance).
- IWMPSettings2::get_mediaAccessRights returns "full"
- Windows Media Player v10 installed, WMSDK v10 installed, Windows XP
(Service Pack 1)
- Unicode Build

Any Ideas?
Thanks,


Code snippit below (bare minimums)
-----------------------------------------

#include <atlbase.h>
#include <atlwin.h>
#include "wmp.h"

CoInitialize(NULL);

// IWMPPlayer
CComPtr<IWMPPlayer4> spPlayer;
HRESULT hr = spPlayer.CoCreateInstance(__uuidof(WindowsMediaPlayer), 0,
CLSCTX_INPROC_SERVER);

// IWMPSettings
CComPtr<IWMPSettings> spSet;
hr = spPlayer->get_settings(&spSet);

// Get Settings2 interface
CComPtr<IWMPSettings2> spSet2;
hr = spSet.QueryInterface(&spSet2);

// get rights
CComBSTR sRights;
hr = spSet2->get_mediaAccessRights(&sRights);

// IWMPMediaCollection
CComPtr<IWMPMediaCollection> spMediaCollection;
hr = spPlayer->get_mediaCollection(&spMediaCollection);

CComPtr<IWMPMedia> spNewMedia;
hr = spMediaCollection->add(L"c:\\media\\test.avi", &spNewMedia);

CoUnitialize();

Back to top
Jim Travis [ms]
Guest





Posted: Sun Oct 17, 2004 6:52 am    Post subject: Re: Strange Behavior with adding to Media Library (WM10) wi Reply with quote

The changes won't commit until the next time the Player runs. If you want it
to commit right away, create a remoted instance of the control.


--
Jim Travis
Microsoft Corp.
Windows Media Player SDK

Download:
http://msdn.microsoft.com/library/default.asp?url=/downloads/list/winmedia.asp

Latest online:
http://msdn.microsoft.com/library/en-us/wmplay10/mmp_sdk/windowsmediaplayer10sdk.asp

Please do not send email directly to this alias as this alias is for
newsgroup purposes only. This posting is provided "AS IS" with no
warranties, and confers no rights. You assume all risk for your use. © 2004
Microsoft Corporation. All rights reserved.

"Scott Ramsay" <sramsay@gonavi.com> wrote in message
news:eSE7xGzsEHA.1216@TK2MSFTNGP10.phx.gbl...
Quote:
Greetings,

I'm attempting to add a single avi to the media library using C++.
Everything runs ok without error. However after my program finishes
executing, the added media does not show up in the Window Media Player
Library.

Am I missing some important call? Some sort of flush call? Does "Add"
requires some minimum item setting e.g. IWMPMedia::setItemInfo

Notes:
- Stepping through with the debugger: all calls return successfully (S_OK)
- The avi is in the media collection of my program if I enumerate after
the
add (only during program instance).
- IWMPSettings2::get_mediaAccessRights returns "full"
- Windows Media Player v10 installed, WMSDK v10 installed, Windows XP
(Service Pack 1)
- Unicode Build

Any Ideas?
Thanks,


Code snippit below (bare minimums)
-----------------------------------------

#include <atlbase.h
#include <atlwin.h
#include "wmp.h"

CoInitialize(NULL);

// IWMPPlayer
CComPtr<IWMPPlayer4> spPlayer;
HRESULT hr = spPlayer.CoCreateInstance(__uuidof(WindowsMediaPlayer), 0,
CLSCTX_INPROC_SERVER);

// IWMPSettings
CComPtr<IWMPSettings> spSet;
hr = spPlayer->get_settings(&spSet);

// Get Settings2 interface
CComPtr<IWMPSettings2> spSet2;
hr = spSet.QueryInterface(&spSet2);

// get rights
CComBSTR sRights;
hr = spSet2->get_mediaAccessRights(&sRights);

// IWMPMediaCollection
CComPtr<IWMPMediaCollection> spMediaCollection;
hr = spPlayer->get_mediaCollection(&spMediaCollection);

CComPtr<IWMPMedia> spNewMedia;
hr = spMediaCollection->add(L"c:\\media\\test.avi", &spNewMedia);

CoUnitialize();


Back to top
 
Post new topic   Reply to topic    WMPTalk.com Forum Index -> SDK All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Microsoft Office Forum New Topics
Powered by phpBB