MediaMetadata:artist 属性
artist
属性是 MediaMetadata
接口的一部分,用于返回或设置要播放的媒体的艺术家、团体、创作者等名称。
值
包含艺术家名称的 String
。
示例
以下示例检查浏览器兼容性并设置媒体会话的当前元数据。
js
if ("mediaSession" in navigator) {
navigator.mediaSession.metadata = new MediaMetadata({
title: "Unforgettable",
artist: "Nat King Cole",
album: "The Ultimate Collection (Remastered)",
artwork: [
{
src: "https://dummyimage.com/96x96",
sizes: "96x96",
type: "image/png",
},
{
src: "https://dummyimage.com/128x128",
sizes: "128x128",
type: "image/png",
},
{
src: "https://dummyimage.com/192x192",
sizes: "192x192",
type: "image/png",
},
{
src: "https://dummyimage.com/256x256",
sizes: "256x256",
type: "image/png",
},
{
src: "https://dummyimage.com/384x384",
sizes: "384x384",
type: "image/png",
},
{
src: "https://dummyimage.com/512x512",
sizes: "512x512",
type: "image/png",
},
],
});
}
规范
规范 |
---|
媒体会话 # dom-mediametadata-artist |
浏览器兼容性
BCD 表格仅在启用 JavaScript 的浏览器中加载。