變更同步處理優先順序
[與此頁面相關聯的功能Windows 媒體播放機 SDK是舊版功能。 它已被 MediaPlayer 取代。 MediaPlayer已針對Windows 10和Windows 11進行優化。 Microsoft 強烈建議新程式碼盡可能使用MediaPlayer,而不是Windows 媒體播放機 SDK。 Microsoft 建議盡可能重寫使用舊版 API 的現有程式碼,以使用新的 API。]
下列範例程式碼會指定 listView 控制項中由 IDC_PLVIEW 識別之每個專案的優先順序值。 以核取記號標示的專案會根據其清單中的順序指派優先順序值。 未核取的專案會指派為零的優先順序值。
void CSyncSettings::SetPriorities()
{
ATLASSERT(m_spPlaylist.p);
long lCount = 0;
CComBSTR bstrAttribute(g_szSyncAttributeNames[m_lCurrentPSIndex]);
long lPriorityCount = 0; // Tracks the next priority value to be assigned.
long lNewPriority = 0; // Contains the new priority value for the playlist.
HRESULT hr = m_spPlaylist->get_count(&lCount);
if(SUCCEEDED(hr) && lCount > 0)
{
HCURSOR hCursor = LoadCursor(NULL, IDC_WAIT);
HCURSOR hCursorOld = SetCursor(hCursor);
// Walk the list.
for(long i = 0; i < lCount; i++)
{
CComPtr<IWMPMedia> spMedia;
BOOL bChecked = ListView_GetCheckState(m_hPlView, i);
if(TRUE == bChecked)
{
// Assign a priority value.
lNewPriority = ++lPriorityCount;
}
else
{
// Not a sync playlist.
lNewPriority = 0;
}
// Set the attribute on the playlist.
hr = m_spPlaylist->get_item(i, &spMedia);
if(SUCCEEDED(hr))
{
WCHAR buffer[30];
_ltow(lNewPriority, buffer, 10);
CComBSTR bstrPriority(buffer);
hr = spMedia->setItemInfo(bstrAttribute, bstrPriority);
}
}
SetCursor(hCursorOld);
}
}
相關主題
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應