almost done but could still use some testing
This commit is contained in:
parent
b7e55296d5
commit
c6e6bd55e1
3 changed files with 33 additions and 35 deletions
|
@ -277,7 +277,6 @@ const analytics: Analytics = {
|
||||||
videoType = passedPlayer.currentSource().type;
|
videoType = passedPlayer.currentSource().type;
|
||||||
videoPlayer = passedPlayer;
|
videoPlayer = passedPlayer;
|
||||||
bitrateAsBitsPerSecond = videoBitrate;
|
bitrateAsBitsPerSecond = videoBitrate;
|
||||||
|
|
||||||
sendPromMetric('time_to_start', timeToStartVideo);
|
sendPromMetric('time_to_start', timeToStartVideo);
|
||||||
},
|
},
|
||||||
error: (message) => {
|
error: (message) => {
|
||||||
|
@ -481,7 +480,7 @@ function sendPromMetric(name: string, value?: number) {
|
||||||
let url = new URL(SDK_API_PATH + '/metric/ui');
|
let url = new URL(SDK_API_PATH + '/metric/ui');
|
||||||
const params = { name: name, value: value ? value.toString() : '' };
|
const params = { name: name, value: value ? value.toString() : '' };
|
||||||
url.search = new URLSearchParams(params).toString();
|
url.search = new URLSearchParams(params).toString();
|
||||||
return fetch(url, { method: 'post' });
|
return fetch(url, { method: 'post' }).catch(function(error){});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// @flow
|
// @flow
|
||||||
import React, { useEffect, useRef, useState } from 'react';
|
import { useEffect } from 'react';
|
||||||
|
|
||||||
const isDev = process.env.NODE_ENV !== 'production';
|
const isDev = process.env.NODE_ENV !== 'production';
|
||||||
|
|
||||||
|
@ -17,7 +17,8 @@ const setLabel = (controlBar, childName, label) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ({ tapToUnmuteRef, tapToRetryRef, setReload, videoTheaterMode,
|
export default ({ tapToUnmuteRef, tapToRetryRef, setReload, videoTheaterMode,
|
||||||
playerRef, autoplaySetting}) => {
|
playerRef, autoplaySetting, player}) => {
|
||||||
|
|
||||||
// Override the player's control text. We override to:
|
// Override the player's control text. We override to:
|
||||||
// 1. Add keyboard shortcut to the tool-tip.
|
// 1. Add keyboard shortcut to the tool-tip.
|
||||||
// 2. Override videojs' i18n and use our own (don't want to have 2 systems).
|
// 2. Override videojs' i18n and use our own (don't want to have 2 systems).
|
||||||
|
@ -112,15 +113,15 @@ export default ({ tapToUnmuteRef, tapToRetryRef, setReload, videoTheaterMode,
|
||||||
// }
|
// }
|
||||||
// }, [adUrl]);
|
// }, [adUrl]);
|
||||||
|
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
const player = playerRef.current;
|
// const player = playerRef.current;
|
||||||
if (player) {
|
// if (player) {
|
||||||
const controlBar = player.getChild('controlBar');
|
// const controlBar = player.getChild('controlBar');
|
||||||
controlBar
|
// controlBar
|
||||||
.getChild('TheaterModeButton')
|
// .getChild('TheaterModeButton')
|
||||||
.controlText(videoTheaterMode ? __('Default Mode (t)') : __('Theater Mode (t)'));
|
// .controlText(videoTheaterMode ? __('Default Mode (t)') : __('Theater Mode (t)'));
|
||||||
}
|
// }
|
||||||
}, [videoTheaterMode]);
|
// }, [videoTheaterMode]);
|
||||||
|
|
||||||
// when user clicks 'Unmute' button, turn audio on and hide unmute button
|
// when user clicks 'Unmute' button, turn audio on and hide unmute button
|
||||||
function unmuteAndHideHint() {
|
function unmuteAndHideHint() {
|
||||||
|
@ -172,24 +173,24 @@ export default ({ tapToUnmuteRef, tapToRetryRef, setReload, videoTheaterMode,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
console.log('RUNNING HERE!')
|
// console.log('RUNNING HERE!')
|
||||||
|
//
|
||||||
const player = playerRef.current;
|
// const player = playerRef.current;
|
||||||
if (player) {
|
// if (player) {
|
||||||
const touchOverlay = player.getChild('TouchOverlay');
|
// const touchOverlay = player.getChild('TouchOverlay');
|
||||||
const controlBar = player.getChild('controlBar') || touchOverlay.getChild('controlBar');
|
// const controlBar = player.getChild('controlBar') || touchOverlay.getChild('controlBar');
|
||||||
const autoplayButton = controlBar.getChild('AutoplayNextButton');
|
// const autoplayButton = controlBar.getChild('AutoplayNextButton');
|
||||||
|
//
|
||||||
if (autoplayButton) {
|
// if (autoplayButton) {
|
||||||
const title = autoplaySetting ? __('Autoplay Next On') : __('Autoplay Next Off');
|
// const title = autoplaySetting ? __('Autoplay Next On') : __('Autoplay Next Off');
|
||||||
|
//
|
||||||
autoplayButton.controlText(title);
|
// autoplayButton.controlText(title);
|
||||||
autoplayButton.setAttribute('aria-label', title);
|
// autoplayButton.setAttribute('aria-label', title);
|
||||||
autoplayButton.setAttribute('aria-checked', autoplaySetting);
|
// autoplayButton.setAttribute('aria-checked', autoplaySetting);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}, [autoplaySetting]);
|
// }, [autoplaySetting]);
|
||||||
|
|
||||||
// Add various event listeners to player
|
// Add various event listeners to player
|
||||||
player.one('play', onInitialPlay);
|
player.one('play', onInitialPlay);
|
||||||
|
|
|
@ -186,10 +186,8 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
||||||
|
|
||||||
const videoJsEvents = events({ tapToUnmuteRef, tapToRetryRef, setReload, videoTheaterMode, playerRef, autoplaySetting, player });
|
const videoJsEvents = events({ tapToUnmuteRef, tapToRetryRef, setReload, videoTheaterMode, playerRef, autoplaySetting, player });
|
||||||
|
|
||||||
unmuteAndHideHint = { events };
|
unmuteAndHideHint = videoJsEvents.unmuteAndHideHint;
|
||||||
retryVideoAfterFailure = { events };
|
retryVideoAfterFailure = videoJsEvents.retryVideoAfterFailure;
|
||||||
|
|
||||||
videoJsEvents.initializeEvents({ player, tapToRetryRef, tapToUnmuteRef });
|
|
||||||
|
|
||||||
// Replace volume bar with custom LBRY volume bar
|
// Replace volume bar with custom LBRY volume bar
|
||||||
LbryVolumeBarClass.replaceExisting(player);
|
LbryVolumeBarClass.replaceExisting(player);
|
||||||
|
|
Loading…
Reference in a new issue