From f801ea4b05c07f423503bfb45d35b5b4a64b0693 Mon Sep 17 00:00:00 2001 From: Jason <84899178+jasonhenriquez@users.noreply.github.com> Date: Tue, 24 Aug 2021 07:36:10 +0000 Subject: [PATCH] Integrate theater mode into mediaplayer (#1589) * Moves theatre mode button to mediaplayer * Accounts for 'Enable Theatre Mode by Default' * Removes unnecessary comment * Removes unnecessary newlines * Rename variable for toggle theatre mode button * Fix issue caused by missing change in rename Co-authored-by: Preston Co-authored-by: PikachuEXE --- src/renderer/assets/img/close_theatre.svg | 1 + src/renderer/assets/img/open_theatre.svg | 1 + .../ft-video-player/ft-video-player.js | 45 +++++++++++++++++++ .../watch-video-info/watch-video-info.sass | 4 -- .../watch-video-info/watch-video-info.vue | 8 ---- src/renderer/videoJS.css | 24 ++++++++-- src/renderer/views/Watch/Watch.vue | 1 - 7 files changed, 68 insertions(+), 16 deletions(-) create mode 100644 src/renderer/assets/img/close_theatre.svg create mode 100644 src/renderer/assets/img/open_theatre.svg diff --git a/src/renderer/assets/img/close_theatre.svg b/src/renderer/assets/img/close_theatre.svg new file mode 100644 index 00000000..220d28e6 --- /dev/null +++ b/src/renderer/assets/img/close_theatre.svg @@ -0,0 +1 @@ + diff --git a/src/renderer/assets/img/open_theatre.svg b/src/renderer/assets/img/open_theatre.svg new file mode 100644 index 00000000..c1e49ac6 --- /dev/null +++ b/src/renderer/assets/img/open_theatre.svg @@ -0,0 +1 @@ + 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 662cbd19..09c7e0ff 100644 --- a/src/renderer/components/ft-video-player/ft-video-player.js +++ b/src/renderer/components/ft-video-player/ft-video-player.js @@ -112,6 +112,7 @@ export default Vue.extend({ 'subsCapsButton', 'audioTrackButton', 'pictureInPictureToggle', + 'toggleTheatreModeButton', 'fullWindowButton', 'qualitySelector', 'fullscreenToggle' @@ -164,6 +165,10 @@ export default Vue.extend({ return this.$store.getters.getDefaultVideoFormat }, + defaultTheatreMode: function () { + return this.$store.getters.getDefaultTheatreMode + }, + autoplayVideos: function () { return this.$store.getters.getAutoplayVideos }, @@ -195,6 +200,7 @@ export default Vue.extend({ this.createFullWindowButton() this.createLoopButton() + this.createToggleTheatreModeButton() this.determineFormatType() this.determineMaxFramerate() }, @@ -966,6 +972,45 @@ export default Vue.extend({ videojs.registerComponent('fullWindowButton', fullWindowButton) }, + createToggleTheatreModeButton: function() { + if (!this.$parent.theatrePossible) { + return + } + + const theatreModeActive = this.defaultTheatreModeActive ? ' vjs-icon-theatre-active' : '' + + const VjsButton = videojs.getComponent('Button') + const toggleTheatreModeButton = videojs.extend(VjsButton, { + constructor: function(player, options) { + VjsButton.call(this, player, options) + }, + handleClick: () => { + this.toggleTheatreMode() + }, + createControlTextEl: function (button) { + return $(button) + .addClass('vjs-button-theatre') + .html($(`
`)) + .attr('title', 'Toggle Theatre Mode') + } + }) + + videojs.registerComponent('toggleTheatreModeButton', toggleTheatreModeButton) + }, + + toggleTheatreMode: function() { + if (!this.player.isFullscreen_) { + const toggleTheatreModeButton = $('#toggleTheatreModeButton') + if (!this.$parent.useTheatreMode) { + toggleTheatreModeButton.addClass('vjs-icon-theatre-active') + } else { + toggleTheatreModeButton.removeClass('vjs-icon-theatre-active') + } + } + + this.$parent.toggleTheatreMode() + }, + createDashQualitySelector: function (levels) { if (levels.levels_.length === 0) { setTimeout(() => { diff --git a/src/renderer/components/watch-video-info/watch-video-info.sass b/src/renderer/components/watch-video-info/watch-video-info.sass index 73047fb0..a6e466d1 100644 --- a/src/renderer/components/watch-video-info/watch-video-info.sass +++ b/src/renderer/components/watch-video-info/watch-video-info.sass @@ -86,7 +86,3 @@ ::v-deep .iconDropdown left: calc(50% - 20px) right: auto - - @media only screen and (max-width: 1350px) - .theatreModeButton - display: none diff --git a/src/renderer/components/watch-video-info/watch-video-info.vue b/src/renderer/components/watch-video-info/watch-video-info.vue index 0d7b0bc3..2ea9960d 100644 --- a/src/renderer/components/watch-video-info/watch-video-info.vue +++ b/src/renderer/components/watch-video-info/watch-video-info.vue @@ -78,14 +78,6 @@ theme="secondary" @click="handleExternalPlayer" /> -