Fix bandwithSelector and livestream selector broken
This commit is contained in:
parent
14fc7bae50
commit
6b1bcb34a7
3 changed files with 13 additions and 48 deletions
|
@ -111,29 +111,6 @@ class HlsQualitySelectorPlugin {
|
|||
concreteButtonInstance.removeClass('vjs-hidden');
|
||||
}
|
||||
|
||||
resolveAutoQualityLabel(includeResolution) {
|
||||
const player = this.player;
|
||||
const vhs = player.tech(true).vhs;
|
||||
|
||||
if (includeResolution && vhs) {
|
||||
const pixelRatio = this.useDevicePixelRatio ? window.devicePixelRatio || 1 : 1;
|
||||
|
||||
const selectedBandwidth = simpleSelector(
|
||||
vhs.playlists.master,
|
||||
vhs.systemBandwidth,
|
||||
parseInt(safeGetComputedStyle(vhs.tech_.el_, 'width'), 10) * pixelRatio,
|
||||
parseInt(safeGetComputedStyle(vhs.tech_.el_, 'height'), 10) * pixelRatio,
|
||||
vhs.limitRenditionByPlayerDimensions
|
||||
);
|
||||
|
||||
const quality = selectedBandwidth.attributes.RESOLUTION.height;
|
||||
|
||||
return __('Auto (%quality%) --[Video quality popup. Long form.]--', { quality: quality + 'p' });
|
||||
} else {
|
||||
return __('Auto --[Video quality. Short form]--');
|
||||
}
|
||||
}
|
||||
|
||||
resolveOriginalQualityLabel(abbreviatedForm, includeResolution) {
|
||||
if (includeResolution && this.config.originalHeight) {
|
||||
return abbreviatedForm
|
||||
|
@ -160,7 +137,7 @@ class HlsQualitySelectorPlugin {
|
|||
let str;
|
||||
switch (text) {
|
||||
case QUALITY_OPTIONS.AUTO:
|
||||
str = this.resolveAutoQualityLabel(true);
|
||||
str = QUALITY_OPTIONS.AUTO;
|
||||
break;
|
||||
case QUALITY_OPTIONS.ORIGINAL:
|
||||
str = this.resolveOriginalQualityLabel(true, false);
|
||||
|
@ -227,6 +204,7 @@ class HlsQualitySelectorPlugin {
|
|||
levelItems = levelItems.map((item) =>
|
||||
item === nextLowestQualityItem ? this.getQualityMenuItem.call(this, nextLowestQualityItemObj) : item
|
||||
);
|
||||
this._currentQuality = nextLowestQualityItemObj.value;
|
||||
}
|
||||
|
||||
levelItems.sort((current, next) => {
|
||||
|
@ -254,7 +232,7 @@ class HlsQualitySelectorPlugin {
|
|||
|
||||
levelItems.push(
|
||||
this.getQualityMenuItem.call(this, {
|
||||
label: this.resolveAutoQualityLabel(true),
|
||||
label: QUALITY_OPTIONS.AUTO,
|
||||
value: QUALITY_OPTIONS.AUTO,
|
||||
selected: !defaultQuality ? true : defaultQuality === QUALITY_OPTIONS.AUTO,
|
||||
})
|
||||
|
|
|
@ -205,19 +205,10 @@ export const lastBandwidthSelector = function() {
|
|||
const hlsQualitySelector = player.hlsQualitySelector;
|
||||
const originalHeight = hlsQualitySelector.config.originalHeight;
|
||||
|
||||
if (originalHeight && hlsQualitySelector) {
|
||||
if (hlsQualitySelector.getCurrentQuality() === 'auto') {
|
||||
if (selectedBandwidth.attributes.RESOLUTION.height === originalHeight) {
|
||||
if (player.claimSrcOriginal && player.currentSrc() !== player.claimSrcOriginal?.src) {
|
||||
setTimeout(() => {
|
||||
const currentTime = player.currentTime();
|
||||
player.src(player.claimSrcOriginal);
|
||||
player.currentTime(currentTime);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hlsQualitySelector?.getCurrentQuality() === 'auto') {
|
||||
hlsQualitySelector._qualityButton.menuButton_.$('.vjs-icon-placeholder').innerHTML = __('Auto(%quality%) --[Video quality popup. Long form.]--', { quality: selectedBandwidth.attributes.RESOLUTION.height + 'p' });
|
||||
}
|
||||
|
||||
|
||||
return selectedBandwidth;
|
||||
};
|
||||
|
|
|
@ -33,8 +33,6 @@ import { lastBandwidthSelector } from './internal/plugins/videojs-http-streaming
|
|||
// const PLAY_TIMEOUT_LIMIT = 2000;
|
||||
const PLAY_POSITION_SAVE_INTERVAL_MS = 15000;
|
||||
|
||||
const USE_ORIGINAL_STREAM_FOR_OPTIMIZED_AUTO = false;
|
||||
|
||||
type Props = {
|
||||
position: number,
|
||||
changeVolume: (number) => void,
|
||||
|
@ -388,15 +386,13 @@ function VideoViewer(props: Props) {
|
|||
player.on('loadedmetadata', () => restorePlaybackRate(player));
|
||||
|
||||
// Override "auto" to use non-vhs url when the quality matches.
|
||||
if (USE_ORIGINAL_STREAM_FOR_OPTIMIZED_AUTO) {
|
||||
player.on('loadedmetadata', () => {
|
||||
const vhs = player.tech(true).vhs;
|
||||
if (vhs) {
|
||||
// https://github.com/videojs/http-streaming/issues/749#issuecomment-606972884
|
||||
vhs.selectPlaylist = lastBandwidthSelector;
|
||||
}
|
||||
});
|
||||
}
|
||||
player.on('loadedmetadata', () => {
|
||||
const vhs = player.tech(true).vhs;
|
||||
if (vhs) {
|
||||
// https://github.com/videojs/http-streaming/issues/749#issuecomment-606972884
|
||||
vhs.selectPlaylist = lastBandwidthSelector;
|
||||
}
|
||||
});
|
||||
|
||||
// used for tracking buffering for watchman
|
||||
player.on('tracking:buffered', doTrackingBuffered);
|
||||
|
|
Loading…
Reference in a new issue