Use a player event to trigger the DASH quality selector creation (#3183)

* Use a player event to trigger the DASH quality selector creation

* Add requested comment
This commit is contained in:
absidue 2023-02-17 02:34:43 +01:00 committed by GitHub
parent e5cf255894
commit a382326a38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 17 deletions

View File

@ -445,15 +445,6 @@ export default defineComponent({
})
}
if (this.useDash) {
// this.dataSetup.plugins.httpSourceSelector = {
// default: 'auto'
// }
// this.player.httpSourceSelector()
this.createDashQualitySelector(this.player.qualityLevels())
}
if (this.autoplayVideos) {
// Calling play() won't happen right away, so a quick timeout will make it function properly.
setTimeout(() => {
@ -498,8 +489,10 @@ export default defineComponent({
this.player.on('wheel', this.mouseScrollSkip)
}
this.player.on('fullscreenchange', this.fullscreenOverlay)
this.player.on('fullscreenchange', this.toggleFullscreenClass)
this.player.on('fullscreenchange', () => {
this.fullscreenOverlay()
this.toggleFullscreenClass()
})
this.player.on('ready', () => {
this.$emit('ready')
@ -511,6 +504,16 @@ export default defineComponent({
})
this.player.one('loadedmetadata', () => {
if (this.useDash) {
// Reserved for switching back to videojs-http-quality-selector if needed
// this.dataSetup.plugins.httpSourceSelector = {
// default: 'auto'
// }
// this.player.httpSourceSelector()
this.createDashQualitySelector(this.player.qualityLevels())
}
this.checkAspectRatio()
})
@ -1501,12 +1504,6 @@ export default defineComponent({
},
createDashQualitySelector: function (levels) {
if (levels.levels_.length === 0) {
setTimeout(() => {
this.createDashQualitySelector(this.player.qualityLevels())
}, 200)
return
}
const adaptiveFormats = this.adaptiveFormats
const activeAdaptiveFormats = this.activeAdaptiveFormats
const setDashQualityLevel = this.setDashQualityLevel