Fix player error modal
Not hidden when we change the video
This commit is contained in:
parent
9dfbf73576
commit
39c0ceee8b
|
@ -36,6 +36,8 @@ class PeerTubePlugin extends Plugin {
|
||||||
private mouseInControlBar = false
|
private mouseInControlBar = false
|
||||||
private mouseInSettings = false
|
private mouseInSettings = false
|
||||||
|
|
||||||
|
private errorModal: videojs.ModalDialog
|
||||||
|
|
||||||
private videoViewOnPlayHandler: (...args: any[]) => void
|
private videoViewOnPlayHandler: (...args: any[]) => void
|
||||||
private videoViewOnSeekedHandler: (...args: any[]) => void
|
private videoViewOnSeekedHandler: (...args: any[]) => void
|
||||||
private videoViewOnEndedHandler: (...args: any[]) => void
|
private videoViewOnEndedHandler: (...args: any[]) => void
|
||||||
|
@ -109,6 +111,8 @@ class PeerTubePlugin extends Plugin {
|
||||||
|
|
||||||
this.player.on('video-change', () => {
|
this.player.on('video-change', () => {
|
||||||
this.initOnVideoChange()
|
this.initOnVideoChange()
|
||||||
|
|
||||||
|
this.hideFatalError()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -130,6 +134,11 @@ class PeerTubePlugin extends Plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
displayFatalError () {
|
displayFatalError () {
|
||||||
|
// Already displayed an error
|
||||||
|
if (this.errorModal) return
|
||||||
|
|
||||||
|
debugLogger('Display fatal error')
|
||||||
|
|
||||||
this.player.loadingSpinner.hide()
|
this.player.loadingSpinner.hide()
|
||||||
|
|
||||||
const buildModal = (error: MediaError) => {
|
const buildModal = (error: MediaError) => {
|
||||||
|
@ -150,17 +159,24 @@ class PeerTubePlugin extends Plugin {
|
||||||
return wrapper
|
return wrapper
|
||||||
}
|
}
|
||||||
|
|
||||||
const modal = this.player.createModal(buildModal(this.player.error()), {
|
this.errorModal = this.player.createModal(buildModal(this.player.error()), {
|
||||||
temporary: false,
|
temporary: true,
|
||||||
uncloseable: true
|
uncloseable: true
|
||||||
})
|
})
|
||||||
modal.addClass('vjs-custom-error-display')
|
this.errorModal.addClass('vjs-custom-error-display')
|
||||||
|
|
||||||
this.player.addClass('vjs-error-display-enabled')
|
this.player.addClass('vjs-error-display-enabled')
|
||||||
}
|
}
|
||||||
|
|
||||||
hideFatalError () {
|
hideFatalError () {
|
||||||
|
if (!this.errorModal) return
|
||||||
|
|
||||||
|
debugLogger('Hiding fatal error')
|
||||||
|
|
||||||
this.player.removeClass('vjs-error-display-enabled')
|
this.player.removeClass('vjs-error-display-enabled')
|
||||||
|
this.player.removeChild(this.errorModal)
|
||||||
|
this.errorModal.close()
|
||||||
|
this.errorModal = undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
private initializePlayer () {
|
private initializePlayer () {
|
||||||
|
|
|
@ -65,9 +65,10 @@ class WebVideoPlugin extends Plugin {
|
||||||
const playbackRate = this.player.playbackRate()
|
const playbackRate = this.player.playbackRate()
|
||||||
const currentTime = this.player.currentTime()
|
const currentTime = this.player.currentTime()
|
||||||
|
|
||||||
// Enable error display now this is our last fallback
|
if (!this.onErrorHandler) {
|
||||||
this.onErrorHandler = () => this.player.peertube().displayFatalError()
|
this.onErrorHandler = () => this.player.peertube().displayFatalError()
|
||||||
this.player.one('error', this.onErrorHandler)
|
this.player.one('error', this.onErrorHandler)
|
||||||
|
}
|
||||||
|
|
||||||
let httpUrl = this.currentVideoFile.fileUrl
|
let httpUrl = this.currentVideoFile.fileUrl
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue