mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 11:42:29 +08:00
fixbug tts(stream) not work on ios safari(17.1+) (#8645)
Co-authored-by: crazywoola <427733928@qq.com>
This commit is contained in:
parent
11d09a92d0
commit
52da5b16e7
|
@ -12,7 +12,7 @@ export default class AudioPlayer {
|
||||||
mediaSource: MediaSource | null
|
mediaSource: MediaSource | null
|
||||||
audio: HTMLAudioElement
|
audio: HTMLAudioElement
|
||||||
audioContext: AudioContext
|
audioContext: AudioContext
|
||||||
sourceBuffer?: SourceBuffer
|
sourceBuffer?: any
|
||||||
cacheBuffers: ArrayBuffer[] = []
|
cacheBuffers: ArrayBuffer[] = []
|
||||||
pauseTimer: number | null = null
|
pauseTimer: number | null = null
|
||||||
msgId: string | undefined
|
msgId: string | undefined
|
||||||
|
@ -33,7 +33,7 @@ export default class AudioPlayer {
|
||||||
this.callback = callback
|
this.callback = callback
|
||||||
|
|
||||||
// Compatible with iphone ios17 ManagedMediaSource
|
// Compatible with iphone ios17 ManagedMediaSource
|
||||||
const MediaSource = window.MediaSource || window.ManagedMediaSource
|
const MediaSource = window.ManagedMediaSource || window.MediaSource
|
||||||
if (!MediaSource) {
|
if (!MediaSource) {
|
||||||
Toast.notify({
|
Toast.notify({
|
||||||
message: 'Your browser does not support audio streaming, if you are using an iPhone, please update to iOS 17.1 or later.',
|
message: 'Your browser does not support audio streaming, if you are using an iPhone, please update to iOS 17.1 or later.',
|
||||||
|
@ -43,6 +43,10 @@ export default class AudioPlayer {
|
||||||
this.mediaSource = MediaSource ? new MediaSource() : null
|
this.mediaSource = MediaSource ? new MediaSource() : null
|
||||||
this.audio = new Audio()
|
this.audio = new Audio()
|
||||||
this.setCallback(callback)
|
this.setCallback(callback)
|
||||||
|
if (!window.MediaSource) { // if use ManagedMediaSource
|
||||||
|
this.audio.disableRemotePlayback = true
|
||||||
|
this.audio.controls = true
|
||||||
|
}
|
||||||
this.audio.src = this.mediaSource ? URL.createObjectURL(this.mediaSource) : ''
|
this.audio.src = this.mediaSource ? URL.createObjectURL(this.mediaSource) : ''
|
||||||
this.audio.autoplay = true
|
this.audio.autoplay = true
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user