From fb1e3e703b4694edc7f599b446f4ac9dc1954006 Mon Sep 17 00:00:00 2001 From: Anthony Date: Fri, 27 Aug 2021 16:08:35 +0200 Subject: [PATCH] hide play button if autoplay next is on --- .../viewers/videoViewer/internal/videojs.jsx | 21 +++++++++++++------ ui/component/viewers/videoViewer/view.jsx | 1 + 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/ui/component/viewers/videoViewer/internal/videojs.jsx b/ui/component/viewers/videoViewer/internal/videojs.jsx index cd6ae9f32..004def234 100644 --- a/ui/component/viewers/videoViewer/internal/videojs.jsx +++ b/ui/component/viewers/videoViewer/internal/videojs.jsx @@ -59,6 +59,7 @@ type Props = { userId: ?number, // allowPreRoll: ?boolean, shareTelemetry: boolean, + showAutoplayCountdown: boolean }; // type VideoJSOptions = { @@ -198,6 +199,7 @@ export default React.memo(function VideoJs(props: Props) { userId, // allowPreRoll, shareTelemetry, + showAutoplayCountdown, } = props; const [reload, setReload] = useState('initial'); @@ -560,10 +562,11 @@ export default React.memo(function VideoJs(props: Props) { player.on('error', onError); player.on('ended', onEnded); - // on ios, center the play button when paused - player.on('pause', function() { - if (IS_IOS) { - const playBT = document.getElementsByClassName('vjs-big-play-button')[0]; + // on ios, show a play button when paused + if (IS_IOS) { + const playBT = document.getElementsByClassName('vjs-big-play-button')[0]; + + player.on('pause', function() { const videoDiv = player.children_[0]; const controlBar = document.getElementsByClassName('vjs-control-bar')[0]; const leftWidth = ((videoDiv.offsetWidth - playBT.offsetWidth) / 2) + 'px'; @@ -573,8 +576,14 @@ export default React.memo(function VideoJs(props: Props) { playBT.style.top = topHeight; playBT.style.left = leftWidth; playBT.style.margin = 0; - } - }); + }); + + player.on('ended', function() { + if (showAutoplayCountdown) { + playBT.style.display = 'none'; + } + }); + } // Replace volume bar with custom LBRY volume bar LbryVolumeBarClass.replaceExisting(player); diff --git a/ui/component/viewers/videoViewer/view.jsx b/ui/component/viewers/videoViewer/view.jsx index e8617d57d..fbac7cb0c 100644 --- a/ui/component/viewers/videoViewer/view.jsx +++ b/ui/component/viewers/videoViewer/view.jsx @@ -336,6 +336,7 @@ function VideoViewer(props: Props) { userId={userId} allowPreRoll={!embedded && !authenticated} shareTelemetry={shareTelemetry} + showAutoplayCountdown={autoplaySetting} /> )}