feat: add MediaMetadata (#2410)

* change browserslist to cover 100% not dead browsers

* feat: add MediaMetadata

* Revert browserslist change

Co-authored-by: Sam Potts <sam@potts.es>
This commit is contained in:
Hashen
2022-02-24 18:12:58 +05:30
committed by GitHub
parent 4632614ced
commit 6bc447b916
6 changed files with 61 additions and 1 deletions

17
src/js/controls.js vendored
View File

@@ -1749,6 +1749,23 @@ const controls = {
});
}
},
// Set media metadata
setMediaMetadata() {
try {
if ('mediaSession' in navigator) {
navigator.mediaSession.metadata = new window.MediaMetadata({
title: this.config.mediaMetadata.title,
artist: this.config.mediaMetadata.artist,
album: this.config.mediaMetadata.album,
artwork: this.config.mediaMetadata.artwork,
});
}
// eslint-disable-next-line no-empty
} catch (e) {}
},
// Add markers
setMarkers() {
if (this.duration > 0 && !this.elements.markers) {
const { points } = this.config.markers;