This commit is contained in:
2026-10-18 19:17:40 +07:00
parent 9542330125
commit c10ed2db01
10 changed files with 283 additions and 9 deletions
+19
View File
@@ -205,6 +205,12 @@ async function refreshHost() {
if (display.value === null) display.value = host.value.preferredDisplayId
if (!host.value.displays.some((d) => d.id === display.value)) display.value = null
}
async function selectAudioOutput(id: string) {
await run(async () => {
await bridge!.selectAudioOutput(id)
await refreshHost()
})
}
onMounted(async () => {
await run(async () => {
if (!bridge) throw new Error('Откройте пульт в приложении Electron')
@@ -268,6 +274,19 @@ onUnmounted(() => {
placeholder="Выберите внешний дисплей"
:input-props="{ 'aria-label': 'Дисплей показа' }"
/>
<label for="audio-output-input">Вывод звука</label>
<n-select
id="audio-output"
:value="host.audioOutputId ?? ''"
:options="[
{ label: 'По умолчанию в системе', value: '' },
...(host.audioOutputs ?? []).map((device) => ({ label: device.label, value: device.id })),
]"
:disabled="isBusy"
:input-props="{ id: 'audio-output-input', 'aria-label': 'Вывод звука' }"
@update:value="selectAudioOutput"
/>
<n-alert v-if="host.audioOutputNotice" type="warning" role="status">{{ host.audioOutputNotice }}</n-alert>
<n-space align="center">
<n-button
v-if="!state?.outputOpen"
+9
View File
@@ -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()