Respect Default Quality Setting
This commit is contained in:
parent
cb6badd6c9
commit
81a2251bd8
|
@ -147,7 +147,7 @@ export default Vue.extend({
|
||||||
if (videoPlayer !== null) {
|
if (videoPlayer !== null) {
|
||||||
if (!this.useDash) {
|
if (!this.useDash) {
|
||||||
qualitySelector(videojs, { showQualitySelectionLabelInControlBar: true })
|
qualitySelector(videojs, { showQualitySelectionLabelInControlBar: true })
|
||||||
await this.determineDefaultQuality()
|
await this.determineDefaultQualityLegacy()
|
||||||
}
|
}
|
||||||
|
|
||||||
this.player = videojs(videoPlayer)
|
this.player = videojs(videoPlayer)
|
||||||
|
@ -168,6 +168,9 @@ export default Vue.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
this.player.httpSourceSelector()
|
this.player.httpSourceSelector()
|
||||||
|
setTimeout(() => {
|
||||||
|
this.determineDefaultQualityDash()
|
||||||
|
}, 400)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.autoplayVideos) {
|
if (this.autoplayVideos) {
|
||||||
|
@ -212,7 +215,7 @@ export default Vue.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
determineDefaultQuality: function () {
|
determineDefaultQualityLegacy: function () {
|
||||||
if (this.useDash) {
|
if (this.useDash) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -225,6 +228,12 @@ export default Vue.extend({
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let defaultQuality = this.defaultQuality
|
||||||
|
|
||||||
|
if (defaultQuality === 'auto') {
|
||||||
|
defaultQuality = 720
|
||||||
|
}
|
||||||
|
|
||||||
let maxAvailableQuality = parseInt(this.sourceList[this.sourceList.length - 1].qualityLabel.replace(/p|k/, ''))
|
let maxAvailableQuality = parseInt(this.sourceList[this.sourceList.length - 1].qualityLabel.replace(/p|k/, ''))
|
||||||
|
|
||||||
if (maxAvailableQuality === 4) {
|
if (maxAvailableQuality === 4) {
|
||||||
|
@ -235,7 +244,7 @@ export default Vue.extend({
|
||||||
maxAvailableQuality = 4320
|
maxAvailableQuality = 4320
|
||||||
}
|
}
|
||||||
|
|
||||||
if (maxAvailableQuality < this.defaultQuality) {
|
if (maxAvailableQuality < defaultQuality) {
|
||||||
this.selectedDefaultQuality = this.sourceList[this.sourceList.length - 1].qualityLabel
|
this.selectedDefaultQuality = this.sourceList[this.sourceList.length - 1].qualityLabel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,7 +259,7 @@ export default Vue.extend({
|
||||||
qualityNumber = 4320
|
qualityNumber = 4320
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.defaultQuality === qualityNumber) {
|
if (defaultQuality === qualityNumber) {
|
||||||
this.selectedDefaultQuality = source.qualityLabel
|
this.selectedDefaultQuality = source.qualityLabel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,10 +271,10 @@ export default Vue.extend({
|
||||||
if (upperQualityNumber === 8) {
|
if (upperQualityNumber === 8) {
|
||||||
upperQualityNumber = 4320
|
upperQualityNumber = 4320
|
||||||
}
|
}
|
||||||
if (this.defaultQuality >= qualityNumber && this.defaultQuality < upperQualityNumber) {
|
if (defaultQuality >= qualityNumber && defaultQuality < upperQualityNumber) {
|
||||||
this.selectedDefaultQuality = source.qualityLabel
|
this.selectedDefaultQuality = source.qualityLabel
|
||||||
}
|
}
|
||||||
} else if (qualityNumber === this.defaultQuality) {
|
} else if (qualityNumber <= defaultQuality) {
|
||||||
this.selectedDefaultQuality = source.qualityLabel
|
this.selectedDefaultQuality = source.qualityLabel
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -275,6 +284,45 @@ export default Vue.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
determineDefaultQualityDash: function () {
|
||||||
|
if (this.defaultQuality === 'auto') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.player.qualityLevels().levels_.sort((a, b) => {
|
||||||
|
return a.height - b.height
|
||||||
|
}).forEach((ql, index, arr) => {
|
||||||
|
const height = ql.height
|
||||||
|
const width = ql.width
|
||||||
|
const quality = width < height ? width : height
|
||||||
|
let upperLevel = null
|
||||||
|
|
||||||
|
if (index < arr.length - 1) {
|
||||||
|
upperLevel = arr[index + 1]
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.defaultQuality === quality) {
|
||||||
|
ql.enabled = true
|
||||||
|
} else if (upperLevel !== null) {
|
||||||
|
const upperHeight = upperLevel.height
|
||||||
|
const upperWidth = upperLevel.width
|
||||||
|
const upperQuality = upperWidth < upperHeight ? upperWidth : upperHeight
|
||||||
|
|
||||||
|
if (this.defaultQuality >= quality && this.defaultQuality < upperQuality) {
|
||||||
|
ql.enabled = true
|
||||||
|
} else {
|
||||||
|
ql.enabled = false
|
||||||
|
}
|
||||||
|
} else if (index === 0 && quality > this.defaultQuality) {
|
||||||
|
ql.enabled = true
|
||||||
|
} else if (index === (arr.length - 1) && quality < this.defaultQuality) {
|
||||||
|
ql.enabled = true
|
||||||
|
} else {
|
||||||
|
ql.enabled = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
enableDashFormat: function () {
|
enableDashFormat: function () {
|
||||||
if (this.dashSrc === null) {
|
if (this.dashSrc === null) {
|
||||||
console.log('No dash format available.')
|
console.log('No dash format available.')
|
||||||
|
|
Loading…
Reference in New Issue