This commit is contained in:
fidoriel 2023-03-19 21:41:49 +00:00
parent bd75ad4576
commit fcf6964d7d

View File

@ -28,6 +28,11 @@ export default class LocalAudioPlayer extends EventEmitter {
return this.audioTracks[this.currentTrackIndex] || {} return this.audioTracks[this.currentTrackIndex] || {}
} }
get hslContentUrl() {
// the hls stream playlist is the same for all tracks
return this.audioTracks[0].relativeContentUrl
}
initialize() { initialize() {
if (document.getElementById('audio-player')) { if (document.getElementById('audio-player')) {
document.getElementById('audio-player').remove() document.getElementById('audio-player').remove()
@ -132,7 +137,7 @@ export default class LocalAudioPlayer extends EventEmitter {
if (!Hls.isSupported()) { if (!Hls.isSupported()) {
console.warn('HLS is not supported - fallback to using audio element') console.warn('HLS is not supported - fallback to using audio element')
this.usingNativeplayer = true this.usingNativeplayer = true
this.player.src = this.currentTrack.relativeContentUrl this.player.src = this.hslContentUrl
this.player.currentTime = this.startTime this.player.currentTime = this.startTime
return return
} }
@ -148,7 +153,7 @@ export default class LocalAudioPlayer extends EventEmitter {
this.hlsInstance.attachMedia(this.player) this.hlsInstance.attachMedia(this.player)
this.hlsInstance.on(Hls.Events.MEDIA_ATTACHED, () => { this.hlsInstance.on(Hls.Events.MEDIA_ATTACHED, () => {
this.hlsInstance.loadSource(this.currentTrack.relativeContentUrl) this.hlsInstance.loadSource(this.hslContentUrl)
this.hlsInstance.on(Hls.Events.MANIFEST_PARSED, () => { this.hlsInstance.on(Hls.Events.MANIFEST_PARSED, () => {
console.log('[HLS] Manifest Parsed') console.log('[HLS] Manifest Parsed')