commit to push up to anton for testing
This commit is contained in:
parent
fb1e3e703b
commit
91fe871be3
3 changed files with 51 additions and 24 deletions
|
@ -151,8 +151,8 @@ const onPlayerReady = (player, options) => {
|
|||
* Never shows if the endscreen plugin is present
|
||||
*/
|
||||
const mobileUi = function(options) {
|
||||
// if (videojs.browser.IS_ANDROID || videojs.browser.IS_IOS) {
|
||||
if (videojs.browser.IS_ANDROID) {
|
||||
if (videojs.browser.IS_ANDROID || videojs.browser.IS_IOS) {
|
||||
// if (videojs.browser.IS_ANDROID) {
|
||||
this.ready(() => {
|
||||
onPlayerReady(this, videojs.mergeOptions(defaults, options));
|
||||
});
|
||||
|
|
|
@ -85,7 +85,7 @@ const VIDEO_JS_OPTIONS = {
|
|||
controls: true,
|
||||
html5: {
|
||||
vhs: {
|
||||
overrideNative: !videojs.browser.IS_ANY_SAFARI, // don't override on safari
|
||||
overrideNative: true, // don't override on safari
|
||||
},
|
||||
},
|
||||
};
|
||||
|
@ -120,6 +120,7 @@ const SEEK_BACKWARD_KEYCODE_5 = ARROW_LEFT_KEYCODE;
|
|||
const SEEK_STEP_5 = 5;
|
||||
const SEEK_STEP = 10; // time to seek in seconds
|
||||
|
||||
// register videojs plugins
|
||||
if (!Object.keys(videojs.getPlugins()).includes('eventTracking')) {
|
||||
videojs.registerPlugin('eventTracking', eventTracking);
|
||||
}
|
||||
|
@ -220,11 +221,6 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
|||
eventTracking: true,
|
||||
overlay: OVERLAY.OVERLAY_DATA,
|
||||
},
|
||||
// fixes problem of errant CC button showing up on iOS
|
||||
// the true fix here is to fix the m3u8 file, see: https://github.com/lbryio/lbry-desktop/pull/6315
|
||||
controlBar: {
|
||||
subsCapsButton: false,
|
||||
},
|
||||
};
|
||||
|
||||
const tapToUnmuteRef = useRef();
|
||||
|
@ -299,29 +295,29 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
|||
// as the listener to update static texts.
|
||||
const player = playerRef.current;
|
||||
if (player) {
|
||||
const controlBar = player.getChild('controlBar');
|
||||
// const controlBar = player.getChild('controlBar');
|
||||
switch (e.type) {
|
||||
case 'play':
|
||||
controlBar.getChild('PlayToggle').controlText(__('Pause (space)'));
|
||||
// controlBar.getChild('PlayToggle').controlText(__('Pause (space)'));
|
||||
break;
|
||||
case 'pause':
|
||||
controlBar.getChild('PlayToggle').controlText(__('Play (space)'));
|
||||
// controlBar.getChild('PlayToggle').controlText(__('Play (space)'));
|
||||
break;
|
||||
case 'volumechange':
|
||||
controlBar
|
||||
.getChild('VolumePanel')
|
||||
.getChild('MuteToggle')
|
||||
.controlText(player.muted() || player.volume() === 0 ? __('Unmute (m)') : __('Mute (m)'));
|
||||
// controlBar
|
||||
// .getChild('VolumePanel')
|
||||
// .getChild('MuteToggle')
|
||||
// .controlText(player.muted() || player.volume() === 0 ? __('Unmute (m)') : __('Mute (m)'));
|
||||
break;
|
||||
case 'fullscreenchange':
|
||||
controlBar
|
||||
.getChild('FullscreenToggle')
|
||||
.controlText(player.isFullscreen() ? __('Exit Fullscreen (f)') : __('Fullscreen (f)'));
|
||||
// controlBar
|
||||
// .getChild('FullscreenToggle')
|
||||
// .controlText(player.isFullscreen() ? __('Exit Fullscreen (f)') : __('Fullscreen (f)'));
|
||||
break;
|
||||
case 'loadstart':
|
||||
// --- Do everything ---
|
||||
controlBar.getChild('PlaybackRateMenuButton').controlText(__('Playback Rate (<, >)'));
|
||||
controlBar.getChild('QualityButton').controlText(__('Quality'));
|
||||
// controlBar.getChild('PlaybackRateMenuButton').controlText(__('Playback Rate (<, >)'));
|
||||
// controlBar.getChild('QualityButton').controlText(__('Quality'));
|
||||
resolveCtrlText({ type: 'play' });
|
||||
resolveCtrlText({ type: 'pause' });
|
||||
resolveCtrlText({ type: 'volumechange' });
|
||||
|
@ -332,7 +328,7 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
|||
// (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
|
||||
// "Toggle Theater mode".
|
||||
controlBar.getChild('Button').controlText(__('Toggle Theater mode (t)'));
|
||||
// controlBar.getChild('Button').controlText(__('Toggle Theater mode (t)'));
|
||||
break;
|
||||
default:
|
||||
if (isDev) throw Error('Unexpected: ' + e.type);
|
||||
|
@ -360,6 +356,7 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
|||
}
|
||||
|
||||
function onError() {
|
||||
console.log('error!');
|
||||
const player = playerRef.current;
|
||||
showTapButton(TAP.RETRY);
|
||||
|
||||
|
@ -571,7 +568,7 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
|||
const controlBar = document.getElementsByClassName('vjs-control-bar')[0];
|
||||
const leftWidth = ((videoDiv.offsetWidth - playBT.offsetWidth) / 2) + 'px';
|
||||
const availableHeight = videoDiv.offsetHeight - controlBar.offsetHeight;
|
||||
const topHeight = (((availableHeight - playBT.offsetHeight) / 2) + 3) + 'px';
|
||||
const topHeight = (((availableHeight - playBT.offsetHeight) / 2) + 11) + 'px';
|
||||
|
||||
playBT.style.top = topHeight;
|
||||
playBT.style.left = leftWidth;
|
||||
|
|
|
@ -212,19 +212,49 @@ function VideoViewer(props: Props) {
|
|||
}
|
||||
|
||||
const shouldPlay = !embedded || autoplayIfEmbedded;
|
||||
|
||||
console.log('should play');
|
||||
console.log(shouldPlay);
|
||||
|
||||
let tryingToPlay = false;
|
||||
|
||||
// TODO: this is causing issues with videos starting randomly
|
||||
// https://blog.videojs.com/autoplay-best-practices-with-video-js/#Programmatic-Autoplay-and-Success-Failure-Detection
|
||||
if (shouldPlay) {
|
||||
// tryingToPlay = true;
|
||||
//
|
||||
// try {
|
||||
// if(!tryingToPlay){
|
||||
// console.log('trying to start playing');
|
||||
// player.play();
|
||||
// } else {
|
||||
// console.log('already starting playing');
|
||||
// }
|
||||
// } catch (err){
|
||||
// console.log('player error');
|
||||
// console.log(err);
|
||||
// }
|
||||
|
||||
const playPromise = player.play();
|
||||
const timeoutPromise = new Promise((resolve, reject) =>
|
||||
setTimeout(() => reject(PLAY_TIMEOUT_ERROR), PLAY_TIMEOUT_LIMIT)
|
||||
);
|
||||
|
||||
Promise.race([playPromise, timeoutPromise]).catch((error) => {
|
||||
console.log('promise error');
|
||||
console.log(error);
|
||||
console.log('promise error');
|
||||
if (typeof error === 'object' && error.name && error.name === 'NotAllowedError') {
|
||||
console.log('running here!')
|
||||
if (player.autoplay() && !player.muted()) {
|
||||
// player.muted(true);
|
||||
player.muted(true);
|
||||
// another version had player.play()
|
||||
player.play()
|
||||
}
|
||||
} else {
|
||||
console.log('other block conditional');
|
||||
player.muted(true);
|
||||
player.play()
|
||||
}
|
||||
setIsLoading(false);
|
||||
setIsPlaying(false);
|
||||
|
@ -289,7 +319,7 @@ function VideoViewer(props: Props) {
|
|||
{isEndededEmbed && <FileViewerEmbeddedEnded uri={uri} />}
|
||||
{embedded && !isEndededEmbed && <FileViewerEmbeddedTitle uri={uri} />}
|
||||
{/* disable this loading behavior because it breaks when player.play() promise hangs */}
|
||||
{isLoading && <LoadingScreen status={__('Loading')} />}
|
||||
{/*{isLoading && <LoadingScreen status={__('Loading')} />}*/}
|
||||
|
||||
{!isFetchingAd && adUrl && (
|
||||
<>
|
||||
|
|
Loading…
Add table
Reference in a new issue