MediaPlayer issue locking up notification:
- From: Rashmi <rashmigp@xxxxxxxxx>
- Date: Tue, 24 Mar 2009 14:05:50 -0700 (PDT)
Hello,
1. What is the best way to get a notification or event when user
clicks on "Update Library" in the Media Player?
2. In one thread I have setup ChangeNotification on "\Application Data
\Microsoft\Media Player" folder using FindFirstChangeNotification,
since this is where the *.mlb file is located on the phone. In another
thread I am creating a list of all the songs in the media library by
walking through the Media Collection as shown below. However once the
following piece of code is executed, I see that I do NOT receive any
new Change Notification, when I press "Update Library" in the Media
Player. I created a standalone application that just watches the
"\Application Data\Microsoft\Media Player" folder, in that application
I get the notification about "update library" after I quit the thread
below. If I do not execute the whole loop and just walk through the
loop just once, then I receive the change notification whenever Media
Player library is updated. I checked for any resource leak or memory
leak and I do not see it. Am I missing anything?
----------------------------------------------------------------------------------------------------------------------------
// Get the 'media collection' interface from m_pCore
which is of type IWMPCore *
if (!SUCCEEDED(m_pCore->get_mediaCollection
(&pMediaCollection)))
{
break;
}
if (!SUCCEEDED(pMediaCollection->getAll
(&pMediaItems)))
{
break;
}
long plCount;
if (!SUCCEEDED(pMediaItems->get_count(&plCount)))
break;
BSTR bAttrNames[3];
bAttrNames[0] = SysAllocString(L"Title");
bAttrNames[1] = SysAllocString(L"Author");
bAttrNames[2] = SysAllocString(L"Album");
for (long i = 0; i < plCount; i++)
{
if (!SUCCEEDED(pMediaItems->get_item(i, &pMedia)))
break;
for (long k = 0; k < 3; k++)
{
BSTR bAttrVal = NULL;
if (SUCCEEDED(pMedia->getItemInfo(bAttrNames
[k], &bAttrVal)))
{
appendToBuff(_pData, bAttrVal);
appendToBuff(_pData, L"\t");
}
}
appendToBuff(_pData, L"\t\t\t\n");
nLinesWritten++;
}
for (long k = 0; k < 3; k++)
SysFreeString(bAttrNames[k]);
//Write to the file.
if (_pData)
free(_pData);
if (pMediaCollection)
pMediaCollection->Release();
if (pMediaItems)
pMediaItems->Release();
if (pMedia)
pMedia->Release();
----------------------------------------------------------------------------------------------------------------------------
Thanks in advance,
Rashmi.
.
- Follow-Ups:
- Re: MediaPlayer issue locking up notification:
- From: Rashmi
- Re: MediaPlayer issue locking up notification:
- Prev by Date: IWMReader and mp3/wma bitrate and sampling rate
- Next by Date: Re: IWMReader and mp3/wma bitrate and sampling rate
- Previous by thread: IWMReader and mp3/wma bitrate and sampling rate
- Next by thread: Re: MediaPlayer issue locking up notification:
- Index(es):
Relevant Pages
|