From c6e6bd55e1e8f1607e1b3ffa0b01d11eadfe8ec9 Mon Sep 17 00:00:00 2001 From: Anthony Date: Mon, 8 Nov 2021 22:32:21 +0100 Subject: [PATCH] almost done but could still use some testing --- ui/analytics.js | 3 +- .../videoViewer/internal/videojs-events.jsx | 59 ++++++++++--------- .../viewers/videoViewer/internal/videojs.jsx | 6 +- 3 files changed, 33 insertions(+), 35 deletions(-) diff --git a/ui/analytics.js b/ui/analytics.js index 4f2e0b0a0..c6f3875cd 100644 --- a/ui/analytics.js +++ b/ui/analytics.js @@ -277,7 +277,6 @@ const analytics: Analytics = { videoType = passedPlayer.currentSource().type; videoPlayer = passedPlayer; bitrateAsBitsPerSecond = videoBitrate; - sendPromMetric('time_to_start', timeToStartVideo); }, error: (message) => { @@ -481,7 +480,7 @@ function sendPromMetric(name: string, value?: number) { let url = new URL(SDK_API_PATH + '/metric/ui'); const params = { name: name, value: value ? value.toString() : '' }; url.search = new URLSearchParams(params).toString(); - return fetch(url, { method: 'post' }); + return fetch(url, { method: 'post' }).catch(function(error){}); } } diff --git a/ui/component/viewers/videoViewer/internal/videojs-events.jsx b/ui/component/viewers/videoViewer/internal/videojs-events.jsx index e2bc1a6a2..c6f428229 100644 --- a/ui/component/viewers/videoViewer/internal/videojs-events.jsx +++ b/ui/component/viewers/videoViewer/internal/videojs-events.jsx @@ -1,5 +1,5 @@ // @flow -import React, { useEffect, useRef, useState } from 'react'; +import { useEffect } from 'react'; const isDev = process.env.NODE_ENV !== 'production'; @@ -17,7 +17,8 @@ const setLabel = (controlBar, childName, label) => { }; export default ({ tapToUnmuteRef, tapToRetryRef, setReload, videoTheaterMode, - playerRef, autoplaySetting}) => { + playerRef, autoplaySetting, player}) => { + // Override the player's control text. We override to: // 1. Add keyboard shortcut to the tool-tip. // 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]); - useEffect(() => { - const player = playerRef.current; - if (player) { - const controlBar = player.getChild('controlBar'); - controlBar - .getChild('TheaterModeButton') - .controlText(videoTheaterMode ? __('Default Mode (t)') : __('Theater Mode (t)')); - } - }, [videoTheaterMode]); + // useEffect(() => { + // const player = playerRef.current; + // if (player) { + // const controlBar = player.getChild('controlBar'); + // controlBar + // .getChild('TheaterModeButton') + // .controlText(videoTheaterMode ? __('Default Mode (t)') : __('Theater Mode (t)')); + // } + // }, [videoTheaterMode]); // when user clicks 'Unmute' button, turn audio on and hide unmute button function unmuteAndHideHint() { @@ -172,24 +173,24 @@ export default ({ tapToUnmuteRef, tapToRetryRef, setReload, videoTheaterMode, } } - useEffect(() => { - console.log('RUNNING HERE!') - - const player = playerRef.current; - if (player) { - const touchOverlay = player.getChild('TouchOverlay'); - const controlBar = player.getChild('controlBar') || touchOverlay.getChild('controlBar'); - const autoplayButton = controlBar.getChild('AutoplayNextButton'); - - if (autoplayButton) { - const title = autoplaySetting ? __('Autoplay Next On') : __('Autoplay Next Off'); - - autoplayButton.controlText(title); - autoplayButton.setAttribute('aria-label', title); - autoplayButton.setAttribute('aria-checked', autoplaySetting); - } - } - }, [autoplaySetting]); + // useEffect(() => { + // console.log('RUNNING HERE!') + // + // const player = playerRef.current; + // if (player) { + // const touchOverlay = player.getChild('TouchOverlay'); + // const controlBar = player.getChild('controlBar') || touchOverlay.getChild('controlBar'); + // const autoplayButton = controlBar.getChild('AutoplayNextButton'); + // + // if (autoplayButton) { + // const title = autoplaySetting ? __('Autoplay Next On') : __('Autoplay Next Off'); + // + // autoplayButton.controlText(title); + // autoplayButton.setAttribute('aria-label', title); + // autoplayButton.setAttribute('aria-checked', autoplaySetting); + // } + // } + // }, [autoplaySetting]); // Add various event listeners to player player.one('play', onInitialPlay); diff --git a/ui/component/viewers/videoViewer/internal/videojs.jsx b/ui/component/viewers/videoViewer/internal/videojs.jsx index 3f4db017a..0082d121a 100644 --- a/ui/component/viewers/videoViewer/internal/videojs.jsx +++ b/ui/component/viewers/videoViewer/internal/videojs.jsx @@ -186,10 +186,8 @@ export default React.memo(function VideoJs(props: Props) { const videoJsEvents = events({ tapToUnmuteRef, tapToRetryRef, setReload, videoTheaterMode, playerRef, autoplaySetting, player }); - unmuteAndHideHint = { events }; - retryVideoAfterFailure = { events }; - - videoJsEvents.initializeEvents({ player, tapToRetryRef, tapToUnmuteRef }); + unmuteAndHideHint = videoJsEvents.unmuteAndHideHint; + retryVideoAfterFailure = videoJsEvents.retryVideoAfterFailure; // Replace volume bar with custom LBRY volume bar LbryVolumeBarClass.replaceExisting(player);