Player.currentMedia

[與此頁面相關聯的功能Windows 媒體播放機 SDK是舊版功能。 MediaPlayer已取代它。 MediaPlayer已針對Windows 10和Windows 11進行優化。 Microsoft 強烈建議新程式碼盡可能使用MediaPlayer,而不是Windows 媒體播放機 SDK。 Microsoft 建議使用舊版 API 的現有程式碼盡可能重寫為使用新的 API。

currentMedia屬性會指定或擷取目前的 Media 物件。

Syntax

播放程式currentMedia

可能的值

這個屬性是可讀寫的 Media 物件。

備註

如果 設定autoStart 屬性為 true,每當您設定 currentMedia時,播放就會自動開始。

這個屬性會採用 Media 物件,其可使用 Playlist取得。item。 若要使用檔案名載入 媒體 專案,請設定 URL 屬性或使用 newMedia

範例

下列 JScript 範例會擷取程式庫中的第一個媒體專案。 然後它會使用 currentMedia 將擷取的媒體專案設為目前的媒體專案,然後顯示目前媒體專案的名稱。 Player物件是以識別碼 = 「Player」 建立的。

// Retrieve the first media item from the library.
var firstMedia = Player.mediaCollection.getAll().item(0);

// Make the retrieved media item the current media item.
Player.currentMedia = firstMedia;

// Display the name of the current media item.
document.write("Found first media item. Name = " + Player.currentMedia.name);

規格需求

需求
版本
Windows 媒體播放機 7.0 版或更新版本。
DLL
Wmp.dll

另請參閱

Media 物件

Player 物件

Player.newMedia

Playlist.item

Settings.autoStart