[]SoundChannel在页面失焦后自动丢失audioBuffer,以致没有声音

页面在焦点时:WebAudioSoundChannel {audioBuffer: AudioBuffer, gain: GainNode, bufferSource: AudioBufferSourceNode, _currentTime: 0, _volume: 1, …}

audioBuffer:AudioBuffer {length: 7364022, duration: 153.417125, sampleRate: 48000, numberOfChannels: 2}
bufferSource:AudioBufferSourceNode {buffer: AudioBuffer, playbackRate: AudioParam, detune: AudioParam, loop: true, loopStart: 0, …}
completeHandler:null
context:AudioContext {baseLatency: 0.01, destination: AudioDestinationNode, currentTime: 3.7706666666666666, sampleRate: 48000, listener: AudioListener, …}
gain:GainNode {gain: AudioParam, context: AudioContext, numberOfInputs: 1, numberOfOutputs: 1, channelCount: 2, …}
isStopped:false
 
页面失焦后:
WebAudioSoundChannel {audioBuffer: AudioBuffer, gain: GainNode, bufferSource: AudioBufferSourceNode, _currentTime: 0, _volume: 1, …}

audioBuffer:null
bufferSource:null
completeHandler:null
context:AudioContext {baseLatency: 0.01, destination: AudioDestinationNode, currentTime: 200.63733333333334, sampleRate: 48000, listener: AudioListener, …}
gain:GainNode {gain: AudioParam, context: AudioContext, numberOfInputs: 1, numberOfOutputs: 1, channelCount: 2, …}
isStopped:true
已邀请:

zodial

赞同来自:

研究了很久,原来是visibilitychange事件时默认自动结束所有声音,
解决方法:Laya.SoundManager.autoStopMusic = false

要回复问题请先

商务合作
商务合作