mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 18:44:16 +00:00
try & catch
This commit is contained in:
parent
e59edfa86f
commit
7c26aba3a6
@ -18,6 +18,7 @@ export default class MediaSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
update(manifest) {
|
update(manifest) {
|
||||||
|
try {
|
||||||
if ("mediaSession" in navigator) {
|
if ("mediaSession" in navigator) {
|
||||||
return navigator.mediaSession.metadata = new MediaMetadata({
|
return navigator.mediaSession.metadata = new MediaMetadata({
|
||||||
title: manifest.title,
|
title: manifest.title,
|
||||||
@ -53,9 +54,13 @@ export default class MediaSession {
|
|||||||
closeIcon: "media_close",
|
closeIcon: "media_close",
|
||||||
notificationIcon: "notification"
|
notificationIcon: "notification"
|
||||||
})
|
})
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateIsPlaying(to, timeElapsed = 0) {
|
updateIsPlaying(to, timeElapsed = 0) {
|
||||||
|
try {
|
||||||
if ("mediaSession" in navigator) {
|
if ("mediaSession" in navigator) {
|
||||||
return navigator.mediaSession.playbackState = to ? "playing" : "paused"
|
return navigator.mediaSession.playbackState = to ? "playing" : "paused"
|
||||||
}
|
}
|
||||||
@ -64,6 +69,9 @@ export default class MediaSession {
|
|||||||
isPlaying: to,
|
isPlaying: to,
|
||||||
elapsed: timeElapsed,
|
elapsed: timeElapsed,
|
||||||
})
|
})
|
||||||
|
} catch {
|
||||||
|
console.error(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
@ -77,6 +85,7 @@ export default class MediaSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleControlsEvent(action) {
|
handleControlsEvent(action) {
|
||||||
|
try {
|
||||||
const message = action.message
|
const message = action.message
|
||||||
|
|
||||||
switch (message) {
|
switch (message) {
|
||||||
@ -115,5 +124,8 @@ export default class MediaSession {
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user