Controls.playItem 方法
[與此頁面相關聯的功能Windows 媒體播放機 SDK是舊版功能。 它已被 MediaPlayer 取代。 MediaPlayer已針對Windows 10和Windows 11進行優化。 Microsoft 強烈建議新程式碼盡可能使用MediaPlayer,而不是Windows 媒體播放機 SDK。 Microsoft 建議盡可能重寫使用舊版 API 的現有程式碼,以使用新的 API。]
playItem方法會播放指定的媒體專案。
語法
Controls.playItem(
theMediaItem
)
參數
-
theMediaItem [in]
-
要播放的媒體物件。
傳回值
這個方法不會傳回值。
備註
不論 [ 設定] 的值為何,媒體專案都會自動載入和播放。autoStart 屬性。 若要載入專案而不自動播放,請設定 [ 設定]。autoStart 至 false,並將值指派給 Player。URL,之後可以呼叫 播放 以開始播放專案。
注意
playItem 僅適用于 currentPlaylist中的專案。 不支援使用已儲存媒體專案的參考呼叫 playItem 。
範例
下列 JScript 範例會使用 playItem 從目前的播放清單播放媒體專案。 要播放的專案會根據其在播放清單中的位置來選擇。 Player物件是以 ID = 「Player」 建立。
// Declare a variable to hold the position of the media item
// in the current playlist. An arbitrary value is supplied here.
var index = 3
// Retrieve the media item at the fourth position in the current playlist.
var media = Player.currentPlaylist.item(index);
// Play the media item.
Player.controls.playItem(media);
規格需求
需求 | 值 |
---|---|
版本 |
Windows 媒體播放機 7.0 版或更新版本。 |
DLL |
|
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應