MediaCollection.getByName 方法

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

getByName方法會擷取具有指定名稱之媒體專案的播放清單。

語法

retVal = MediaCollection.getByName(
  name
)

參數

name [in]

包含 名稱的字串。

傳回值

這個方法會傳回 Playlist 物件。

備註

若要使用此方法,需要程式庫的讀取權限。 如需詳細資訊,請參閱 程式庫存取

範例

下列 JScript 範例使用 MediaCollectiongetByName 從程式庫擷取三個專案。 然後,每個專案都會附加至目前的播放清單。 Player物件是以 ID=「Player」 建立的。

// In each case, use the name exactly as it appears in the library.
// Windows Media Player does not include file name extensions or file paths
// in the name. Internet URLs include the entire path, but not the 
// file name extension.

// Get a playlist object that contains an Internet URL.
var One = Player.mediaCollection.getByName("https://www.proseware.com/Media/Laure");
 
// Get a playlist object that contains a file on a network server.
var Two = Player.mediaCollection.getByName("Jeanne");

// Get a playlist object that contains a file on a local drive.
var Three = Player.mediaCollection.getByName("house");

// Append each item to the current playlist. Since each playlist retrieved
// using getByName contains one digital media item, use Playlist.item with
// an index of zero to reference that item.
Player.currentPlaylist.appendItem(One.item(0));
Player.currentPlaylist.appendItem(Two.item(0));
Player.currentPlaylist.appendItem(Three.item(0));

規格需求

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

另請參閱

MediaCollection 物件

Playlist 物件

Settings.mediaAccessRights

Settings.requestMediaAccessRights