MediaMetadata
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
MediaMetadata
はメディアセッション API のインターフェイスで、ウェブページがプラットフォーム UI に表示するためのリッチメディアメタデータを提供することができます。
コンストラクター
MediaMetadata()
-
新しい
MediaMetaData
オブジェクトを生成します。
インスタンスプロパティ
MediaMetadata.title
-
再生されるメディアのタイトルを返したり設定したりします。
MediaMetadata.artist
-
再生されるメディアのアーティスト、グループ、作者の名前を返したり設定したりします。
MediaMetadata.album
-
再生されるメディアのアルバムまたはコレクションの名前を返したり設定したりします。
MediaMetadata.artwork
-
再生しているメディアに関連付けられた画像の配列を返したり設定したりします。
例
以下の例では、ブラウザーとの互換性を調べ、メディアセッションの現在のメタデータを設定しています。
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",
},
],
});
}
仕様書
Specification |
---|
Media Session # the-mediametadata-interface |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
MediaMetadata | ||||||||||||
MediaMetadata() constructor | ||||||||||||
album | ||||||||||||
artist | ||||||||||||
artwork | ||||||||||||
chapterInfo | ||||||||||||
title |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- Partial support
- Partial support
- No support
- No support
- Experimental. Expect behavior to change in the future.
- See implementation notes.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.