From 1e5895a8c65603b94e92722f55d268962e3f2d84 Mon Sep 17 00:00:00 2001 From: absidue <48293849+absidue@users.noreply.github.com> Date: Mon, 2 May 2022 13:50:23 +0200 Subject: [PATCH] Hide Picture in Picture button and disable shortcut for audio formats (#2227) --- .../ft-video-player/ft-video-player.js | 2 +- src/renderer/views/Watch/Watch.js | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/renderer/components/ft-video-player/ft-video-player.js b/src/renderer/components/ft-video-player/ft-video-player.js index f50c888e..9b9f0816 100644 --- a/src/renderer/components/ft-video-player/ft-video-player.js +++ b/src/renderer/components/ft-video-player/ft-video-player.js @@ -1578,7 +1578,7 @@ export default Vue.extend({ // I Key event.preventDefault() // Toggle Picture in Picture Mode - if (!this.player.isInPictureInPicture()) { + if (this.format !== 'audio' && !this.player.isInPictureInPicture()) { this.player.requestPictureInPicture() } else if (this.player.isInPictureInPicture()) { this.player.exitPictureInPicture() diff --git a/src/renderer/views/Watch/Watch.js b/src/renderer/views/Watch/Watch.js index 30927717..c08040f9 100644 --- a/src/renderer/views/Watch/Watch.js +++ b/src/renderer/views/Watch/Watch.js @@ -75,7 +75,8 @@ export default Vue.extend({ playlistId: '', timestamp: null, playNextTimeout: null, - playNextCountDownIntervalId: null + playNextCountDownIntervalId: null, + pictureInPictureButtonInverval: null } }, computed: { @@ -174,6 +175,21 @@ export default Vue.extend({ } break } + }, + activeFormat: function (format) { + clearInterval(this.pictureInPictureButtonInverval) + + // only hide/show the button once the player is available + this.pictureInPictureButtonInverval = setInterval(() => { + if (!this.hidePlayer) { + if (format === 'audio') { + document.querySelector('.vjs-picture-in-picture-control').classList.add('vjs-hidden') + } else { + document.querySelector('.vjs-picture-in-picture-control').classList.remove('vjs-hidden') + } + clearInterval(this.pictureInPictureButtonInverval) + } + }, 100) } }, mounted: function () {