Fix captions in HTTP fallback
This commit is contained in:
parent
f242c2e01e
commit
c32bf839c1
|
@ -254,6 +254,10 @@ function loadLocaleInVideoJS (serverUrl: string, videojs: any, locale: string) {
|
|||
loadLocaleInVideoJS.cache[path] = json
|
||||
return json
|
||||
})
|
||||
.catch(err => {
|
||||
console.error('Cannot get player translations', err)
|
||||
return undefined
|
||||
})
|
||||
}
|
||||
|
||||
const completeLocale = getCompleteLocale(locale)
|
||||
|
@ -270,6 +274,10 @@ function getServerTranslations (serverUrl: string, locale: string) {
|
|||
|
||||
return fetch(path + '/server.json')
|
||||
.then(res => res.json())
|
||||
.catch(err => {
|
||||
console.error('Cannot get server translations', err)
|
||||
return undefined
|
||||
})
|
||||
}
|
||||
|
||||
// ############################################################################
|
||||
|
|
|
@ -620,6 +620,9 @@ class PeerTubePlugin extends Plugin {
|
|||
this.player.src = this.savePlayerSrcFunction
|
||||
this.player.src(httpUrl)
|
||||
|
||||
// We changed the source, so reinit captions
|
||||
this.initCaptions()
|
||||
|
||||
return this.tryToPlay(err => {
|
||||
if (err && done) return done(err)
|
||||
|
||||
|
@ -720,6 +723,8 @@ class PeerTubePlugin extends Plugin {
|
|||
default: this.defaultSubtitle === caption.language
|
||||
}, false)
|
||||
}
|
||||
|
||||
this.player.trigger('captionsChanged')
|
||||
}
|
||||
|
||||
// Thanks: https://github.com/videojs/video.js/issues/4460#issuecomment-312861657
|
||||
|
|
|
@ -48,6 +48,19 @@ class SettingsMenuItem extends MenuItem {
|
|||
// Update on rate change
|
||||
player.on('ratechange', this.submenuClickHandler)
|
||||
|
||||
if (subMenuName === 'CaptionsButton') {
|
||||
// Hack to regenerate captions on HTTP fallback
|
||||
player.on('captionsChanged', () => {
|
||||
setTimeout(() => {
|
||||
this.settingsSubMenuEl_.innerHTML = ''
|
||||
this.settingsSubMenuEl_.appendChild(this.subMenu.menu.el_)
|
||||
this.update()
|
||||
this.bindClickEvents()
|
||||
|
||||
}, 0)
|
||||
})
|
||||
}
|
||||
|
||||
this.reset()
|
||||
}, 0)
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue