Use non-VHS link when "auto" matches non-VHS quality
The ideas is that the "optimized" version (same height as original) is badly done, so display the original instead behind the scenes.
This commit is contained in:
parent
6478da923f
commit
257011b62d
3 changed files with 33 additions and 1 deletions
|
@ -1,2 +1,3 @@
|
||||||
**/plugins/inline-attachment/**
|
**/plugins/inline-attachment/**
|
||||||
|
**/plugins/videojs-http-streaming--override/playlist-selectors.js
|
||||||
**/ui/constants/errors.js
|
**/ui/constants/errors.js
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* eslint-disable */
|
||||||
import window from 'global/window';
|
import window from 'global/window';
|
||||||
import Config from './config';
|
import Config from './config';
|
||||||
import Playlist from './playlist';
|
import Playlist from './playlist';
|
||||||
|
@ -192,11 +193,31 @@ export const simpleSelector = function(
|
||||||
export const lastBandwidthSelector = function() {
|
export const lastBandwidthSelector = function() {
|
||||||
const pixelRatio = this.useDevicePixelRatio ? window.devicePixelRatio || 1 : 1;
|
const pixelRatio = this.useDevicePixelRatio ? window.devicePixelRatio || 1 : 1;
|
||||||
|
|
||||||
return simpleSelector(
|
const selectedBandwidth = simpleSelector(
|
||||||
this.playlists.master,
|
this.playlists.master,
|
||||||
this.systemBandwidth,
|
this.systemBandwidth,
|
||||||
parseInt(safeGetComputedStyle(this.tech_.el(), 'width'), 10) * pixelRatio,
|
parseInt(safeGetComputedStyle(this.tech_.el(), 'width'), 10) * pixelRatio,
|
||||||
parseInt(safeGetComputedStyle(this.tech_.el(), 'height'), 10) * pixelRatio,
|
parseInt(safeGetComputedStyle(this.tech_.el(), 'height'), 10) * pixelRatio,
|
||||||
this.limitRenditionByPlayerDimensions
|
this.limitRenditionByPlayerDimensions
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const player = this.player_;
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return selectedBandwidth;
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,6 +27,7 @@ import type { HomepageCat } from 'util/buildHomepage';
|
||||||
import debounce from 'util/debounce';
|
import debounce from 'util/debounce';
|
||||||
import { formatLbryUrlForWeb, generateListSearchUrlParams } from 'util/url';
|
import { formatLbryUrlForWeb, generateListSearchUrlParams } from 'util/url';
|
||||||
import useInterval from 'effects/use-interval';
|
import useInterval from 'effects/use-interval';
|
||||||
|
import { lastBandwidthSelector } from './internal/plugins/videojs-http-streaming--override/playlist-selectors';
|
||||||
|
|
||||||
// const PLAY_TIMEOUT_ERROR = 'play_timeout_error';
|
// const PLAY_TIMEOUT_ERROR = 'play_timeout_error';
|
||||||
// const PLAY_TIMEOUT_LIMIT = 2000;
|
// const PLAY_TIMEOUT_LIMIT = 2000;
|
||||||
|
@ -382,6 +383,15 @@ function VideoViewer(props: Props) {
|
||||||
// re-factoring.
|
// re-factoring.
|
||||||
player.on('loadedmetadata', () => restorePlaybackRate(player));
|
player.on('loadedmetadata', () => restorePlaybackRate(player));
|
||||||
|
|
||||||
|
// Override "auto" to use non-vhs url when the quality matches.
|
||||||
|
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
|
// used for tracking buffering for watchman
|
||||||
player.on('tracking:buffered', doTrackingBuffered);
|
player.on('tracking:buffered', doTrackingBuffered);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue