up
This commit is contained in:
@@ -15,6 +15,7 @@ const imageError = ref(false)
|
||||
const timerDisplay = useScreenTimer(() => state.value)
|
||||
const bridge = window.screenBridge!
|
||||
let player: MediaPlayer | undefined
|
||||
let disposed = false
|
||||
let unsubscribe: (() => void) | undefined
|
||||
let revision = -1
|
||||
let sceneToken = ''
|
||||
@@ -86,6 +87,7 @@ async function prepareScene(snapshot: State) {
|
||||
}
|
||||
}
|
||||
function apply(value: State) {
|
||||
if (disposed) return
|
||||
if (value.revision <= revision) return
|
||||
revision = value.revision
|
||||
state.value = value
|
||||
@@ -97,6 +99,12 @@ function apply(value: State) {
|
||||
}
|
||||
}
|
||||
onMounted(async () => {
|
||||
try {
|
||||
await bridge.prepareAudioOutput()
|
||||
} catch {
|
||||
return // Ошибка устройства отображается в пульте; не запускать звук на другом выходе.
|
||||
}
|
||||
if (disposed) return
|
||||
player = new MediaPlayer(
|
||||
{ audio: audio.value!, video: video.value!, music: [musicA.value!, musicB.value!] },
|
||||
(report) => bridge.report(report),
|
||||
@@ -105,6 +113,7 @@ onMounted(async () => {
|
||||
apply(await bridge.state())
|
||||
})
|
||||
onUnmounted(() => {
|
||||
disposed = true
|
||||
sceneAbort?.abort()
|
||||
unsubscribe?.()
|
||||
player?.destroy()
|
||||
|
||||
Reference in New Issue
Block a user