fix another race condition
This commit is contained in:
parent
a7e3bceb6c
commit
9b7193b013
2 changed files with 37 additions and 21 deletions
|
@ -296,10 +296,14 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
||||||
const controlBar = player.getChild('controlBar');
|
const controlBar = player.getChild('controlBar');
|
||||||
switch (e.type) {
|
switch (e.type) {
|
||||||
case 'play':
|
case 'play':
|
||||||
controlBar.getChild('PlayToggle').controlText(__('Pause (space)'));
|
controlBar
|
||||||
|
.getChild('PlayToggle')
|
||||||
|
.controlText(__('Pause (space)'));
|
||||||
break;
|
break;
|
||||||
case 'pause':
|
case 'pause':
|
||||||
controlBar.getChild('PlayToggle').controlText(__('Play (space)'));
|
controlBar
|
||||||
|
.getChild('PlayToggle')
|
||||||
|
.controlText(__('Play (space)'));
|
||||||
break;
|
break;
|
||||||
case 'volumechange':
|
case 'volumechange':
|
||||||
controlBar
|
controlBar
|
||||||
|
@ -314,8 +318,12 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
||||||
break;
|
break;
|
||||||
case 'loadstart':
|
case 'loadstart':
|
||||||
// --- Do everything ---
|
// --- Do everything ---
|
||||||
controlBar.getChild('PlaybackRateMenuButton').controlText(__('Playback Rate (<, >)'));
|
controlBar
|
||||||
controlBar.getChild('QualityButton').controlText(__('Quality'));
|
.getChild('PlaybackRateMenuButton')
|
||||||
|
.controlText(__('Playback Rate (<, >)'));
|
||||||
|
controlBar
|
||||||
|
.getChild('QualityButton')
|
||||||
|
.controlText(__('Quality'));
|
||||||
resolveCtrlText({ type: 'play' });
|
resolveCtrlText({ type: 'play' });
|
||||||
resolveCtrlText({ type: 'pause' });
|
resolveCtrlText({ type: 'pause' });
|
||||||
resolveCtrlText({ type: 'volumechange' });
|
resolveCtrlText({ type: 'volumechange' });
|
||||||
|
@ -325,8 +333,10 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
||||||
// clashes if we add a new button in the future.
|
// clashes if we add a new button in the future.
|
||||||
// (2) We'll have to get 'makeSelectClientSetting(SETTINGS.VIDEO_THEATER_MODE)'
|
// (2) We'll have to get 'makeSelectClientSetting(SETTINGS.VIDEO_THEATER_MODE)'
|
||||||
// as a prop here so we can say "Theater mode|Default mode" instead of
|
// as a prop here so we can say "Theater mode|Default mode" instead of
|
||||||
// "Toggle Theather mode".
|
// "Toggle Theater mode".
|
||||||
controlBar.getChild('Button').controlText(__('Toggle Theater mode (t)'));
|
controlBar
|
||||||
|
.getChild('Button')
|
||||||
|
.controlText(__('Toggle Theater mode (t)'));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (isDev) throw Error('Unexpected: ' + e.type);
|
if (isDev) throw Error('Unexpected: ' + e.type);
|
||||||
|
@ -509,7 +519,11 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
||||||
// override type if we receive an .m3u8 (transcoded mp4)
|
// override type if we receive an .m3u8 (transcoded mp4)
|
||||||
// do we need to check if explicitly redirected
|
// do we need to check if explicitly redirected
|
||||||
// or is checking extension only a safer method
|
// or is checking extension only a safer method
|
||||||
if (response && response.redirected && response.url && response.url.endsWith('m3u8')) {
|
if (response &&
|
||||||
|
response.redirected &&
|
||||||
|
response.url &&
|
||||||
|
response.url.endsWith('m3u8')
|
||||||
|
) {
|
||||||
finalType = 'application/x-mpegURL';
|
finalType = 'application/x-mpegURL';
|
||||||
finalSource = response.url;
|
finalSource = response.url;
|
||||||
}
|
}
|
||||||
|
@ -562,9 +576,6 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
||||||
// initialize mobile UI
|
// initialize mobile UI
|
||||||
player.mobileUi(); // Inits mobile version. No-op if Desktop.
|
player.mobileUi(); // Inits mobile version. No-op if Desktop.
|
||||||
|
|
||||||
// I think this is a callback function
|
|
||||||
onPlayerReady(player);
|
|
||||||
|
|
||||||
// Add quality selector to player
|
// Add quality selector to player
|
||||||
player.hlsQualitySelector({
|
player.hlsQualitySelector({
|
||||||
displayCurrentQuality: true,
|
displayCurrentQuality: true,
|
||||||
|
@ -577,17 +588,22 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
||||||
userId: userId,
|
userId: userId,
|
||||||
});
|
});
|
||||||
|
|
||||||
// player.aniview();
|
|
||||||
|
|
||||||
player.ima({
|
|
||||||
// id: 'ad_content_video',
|
|
||||||
vpaidMode: google.ima.ImaSdkSettings.VpaidMode.INSECURE,
|
|
||||||
adTagUrl: macroUrl,
|
|
||||||
});
|
|
||||||
|
|
||||||
// set playsinline for mobile
|
// set playsinline for mobile
|
||||||
// TODO: make this better
|
// TODO: make this better
|
||||||
player.children_[0].setAttribute('playsinline', '');
|
player.children_[0].setAttribute('playsinline', '');
|
||||||
|
|
||||||
|
// I think this is a callback function
|
||||||
|
onPlayerReady(player);
|
||||||
|
});
|
||||||
|
|
||||||
|
// pre-roll ads
|
||||||
|
// This must be initialized earlier than everything else
|
||||||
|
// otherwise a race condition occurs if we place this in the onReady call back
|
||||||
|
// player.aniview();
|
||||||
|
vjs.ima({
|
||||||
|
// $FlowFixMe
|
||||||
|
vpaidMode: google.ima.ImaSdkSettings.VpaidMode.INSECURE,
|
||||||
|
adTagUrl: macroUrl,
|
||||||
});
|
});
|
||||||
|
|
||||||
// fixes #3498 (https://github.com/lbryio/lbry-desktop/issues/3498)
|
// fixes #3498 (https://github.com/lbryio/lbry-desktop/issues/3498)
|
||||||
|
@ -674,7 +690,7 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
document.body.removeChild(script);
|
document.body.removeChild(script);
|
||||||
};
|
};
|
||||||
}, [source, reload]);
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
|
|
|
@ -198,7 +198,7 @@ function VideoViewer(props: Props) {
|
||||||
handlePosition(player);
|
handlePosition(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onDispose(player) {
|
function onDispose(event, player) {
|
||||||
handlePosition(player);
|
handlePosition(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,7 +258,7 @@ function VideoViewer(props: Props) {
|
||||||
player.on('ended', onEnded);
|
player.on('ended', onEnded);
|
||||||
player.on('play', onPlay);
|
player.on('play', onPlay);
|
||||||
player.on('pause', onPause);
|
player.on('pause', onPause);
|
||||||
player.on('dispose', onDispose);
|
player.on('dispose', (event) => onDispose(event, player));
|
||||||
player.on('error', () => {
|
player.on('error', () => {
|
||||||
const error = player.error();
|
const error = player.error();
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue