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) {
|
||||
try {
|
||||
if ("mediaSession" in navigator) {
|
||||
return navigator.mediaSession.metadata = new MediaMetadata({
|
||||
title: manifest.title,
|
||||
@ -53,9 +54,13 @@ export default class MediaSession {
|
||||
closeIcon: "media_close",
|
||||
notificationIcon: "notification"
|
||||
})
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}
|
||||
|
||||
updateIsPlaying(to, timeElapsed = 0) {
|
||||
try {
|
||||
if ("mediaSession" in navigator) {
|
||||
return navigator.mediaSession.playbackState = to ? "playing" : "paused"
|
||||
}
|
||||
@ -64,6 +69,9 @@ export default class MediaSession {
|
||||
isPlaying: to,
|
||||
elapsed: timeElapsed,
|
||||
})
|
||||
} catch {
|
||||
console.error(error)
|
||||
}
|
||||
}
|
||||
|
||||
destroy() {
|
||||
@ -77,6 +85,7 @@ export default class MediaSession {
|
||||
}
|
||||
|
||||
handleControlsEvent(action) {
|
||||
try {
|
||||
const message = action.message
|
||||
|
||||
switch (message) {
|
||||
@ -115,5 +124,8 @@ export default class MediaSession {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user