fix(asr): [PKG-ASR-07] apply native playback volume only once

This commit is contained in:
Harvey Zhao committed 2026-09-13 15:22:40 +08:00
1 parent 93208e59e1
commit 3e3bed2b93
19 files changed
+2780 -44

No files matched your search

@@ -111,11 +111,6 @@ export class AudioGraph {
gain.connect(context.destination)
}
volume(value: number) {
if (this.gain)
this.gain.gain.value = value
}
disconnect() {
if (this.recorder) {
this.recorder.port.onmessage = null
@@ -110,10 +110,6 @@ export class Capture {
}
}
volume(value: number) {
this.graph?.volume(value)
}
stop(terminal = false) {
this.terminal ||= terminal
this.pause()
@@ -12,21 +12,18 @@ export default function artplayerPluginAsr(option: AsrOptions = {}) {
throw new Error('Could not create ASR subtitle layer')
const subtitles = createSubtitles(layer, length, autoHideTimeout)
const capture = new Capture(art.video, { interval, sampleRate, onAudioChunk }, subtitles.append)
const volume = () => capture.volume(art.volume)
const play = () => capture.start()
const pause = () => capture.pause()
const restart = () => capture.restart()
const stop = () => capture.stop()
const destroy = () => {
subtitles.destroy()
art.off('video:volumechange', volume)
art.off('play', play)
art.off('pause', pause)
art.off('restart', restart)
art.off('destroy', destroy)
return capture.stop(true)
}
art.on('video:volumechange', volume)
art.on('play', play)
art.on('pause', pause)
art.on('restart', restart)