Media.getAttributeName 方法

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

getAttributeName方法會擷取對應至指定索引的屬性名稱。

語法

strRetVal = Media.getAttributeName(
  index
)

參數

index [in]

包含 屬性索引 () 的數位。

傳回值

這個方法會傳回 String ,指定屬性的名稱。

備註

傳回的屬性名稱可以與 getItemInfo 搭配使用,以擷取特定具名屬性的值。

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

如需Windows 媒體播放機支援之屬性的詳細資訊,請參閱 Windows 媒體播放機屬性參考

Windows 媒體播放機 10 行動裝置版:除非透過媒體集合從專案擷取這些屬性,否則媒體專案的屬性只能在播放期間使用。

範例

下列 JScript 範例使用 MediagetAttributeName ,以填滿名為 myText 的 HTML 文字區域,以及目前媒體專案每個屬性的索引和名稱。 Player物件是以識別碼 = 「Player」 建立的。

// Store the current media object.
var cm = Player.currentMedia;

// Get the number of attributes for the current media. 
var atCount = cm.attributeCount;

// Loop through the attribute list.
for(var i=0; i < atCount; i++){
   
   // Print each attribute index and name.   
   myText.value += "Attribute " + i +": ";
   myText.value += cm.getAttributeName(i);
   myText.value += "\n";
}

規格需求

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

另請參閱

Media 物件

Media.attributeCount

Media.getItemInfo

Settings.mediaAccessRights

Settings.requestMediaAccessRights