MediaCollection.getByGenre 方法
[與此頁面相關聯的功能Windows 媒體播放機 SDK是舊版功能。 MediaPlayer已取代它。 MediaPlayer已針對Windows 10和Windows 11進行優化。 Microsoft 強烈建議新程式碼盡可能使用MediaPlayer,而不是Windows 媒體播放機 SDK。 Microsoft 建議使用舊版 API 的現有程式碼盡可能重寫為使用新的 API。
getByGenre方法會擷取具有指定內容類型的媒體專案的播放清單。
語法
retVal = MediaCollection.getByGenre(
genre
)
參數
-
內容類型 [in]
-
包含 內容類型名稱的字串。
傳回值
這個方法會傳回 Playlist 物件。
備註
若要使用此方法,需要程式庫的讀取權限。 如需詳細資訊,請參閱 程式庫存取。
範例
下列 JScript 範例使用 MediaCollection。getByGenre 以擷取媒體專案的播放清單。 播放清單包含 HTML TEXT 輸入元素中名為 GetGenre 的使用者所指定的內容類型專案。 Player物件是以識別碼 = 「Player」 建立的。
<!-- Use an HTML BUTTON element to create the playlist and play
the media items. -->
<INPUT TYPE = "BUTTON"
NAME = "PlayGenre"
ID = "PlayGenre"
VALUE = "Play Genre"
onClick = "
/* Retrieve the genre text from the user. */
var genre = GetGenre.value;
/* Create the playlist using getByGenre. */
var pl = Player.mediaCollection.getByGenre(genre);
/* Make the new playlist the current playlist. */
Player.currentPlaylist = pl;
/* Play the digital media item in the new playlist. */
Player.controls.play();
">
規格需求
需求 | 值 |
---|---|
版本 |
Windows 媒體播放機 7.0 版或更新版本。 |
DLL |
|
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應