From 75d57835876132384401005fb685033c4b260ff8 Mon Sep 17 00:00:00 2001 From: Stephen Cameron Date: Thu, 20 Jul 2017 15:31:53 +0200 Subject: [PATCH] Fix #1429 @3.5 --- js/libs/fluidbook/fluidbook.resize.js | 11 ++++++ js/libs/fluidbook/fluidbook.video.js | 49 ++++++++++++++++++++++++++- 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/js/libs/fluidbook/fluidbook.resize.js b/js/libs/fluidbook/fluidbook.resize.js index a7400304..1a217236 100644 --- a/js/libs/fluidbook/fluidbook.resize.js +++ b/js/libs/fluidbook/fluidbook.resize.js @@ -261,6 +261,16 @@ FluidbookResize.prototype = { var changeOrientation = this.orientation != ''; var o = this.fluidbook.support.getOrientation(); var newo; + + // If there is a full screen video playing, we must abort any orientation change + // because it will destroy the player and interrupt the video playback. + if (this.fluidbook.video.isVideoFullscreen()) { + //fb('### Full screen video detected -- aborting Fluidbook orientation change...'); + this.fluidbook.video.resizeControls(); + return false; + } + + if (o == 0 || o == 180) { newo = 'portrait'; $('body').removeClass('landscape'); @@ -279,6 +289,7 @@ FluidbookResize.prototype = { this.fluidbook.displayOnePage = (this.orientation == 'portrait'); if (changeOrientation) { + //console.warn('Orientation change! ' + this.orientation); $(this.fluidbook).trigger('fluidbook.resize.beforeOrientationChange'); this.fluidbook.zoom.resetZoom(); this.fluidbook.pageTransition(); diff --git a/js/libs/fluidbook/fluidbook.video.js b/js/libs/fluidbook/fluidbook.video.js index 931e5530..c6cc5b32 100644 --- a/js/libs/fluidbook/fluidbook.video.js +++ b/js/libs/fluidbook/fluidbook.video.js @@ -3,11 +3,12 @@ function FluidbookVideo(fluidbook) { var $this = this; this.players = {}; + this.fullscreenActive = false; // When set to true, this blocks page updates that would interrupt the video // Remove videos before page transition so we can properly handle page turns // and orientation changes (switching from dual page to single page layout and vice-versa) $(fluidbook).on('fluidbook.beforePageTransition', function () { - //fb('triggered beforePageTransition -- ' + $this.fluidbook.resize.orientation); + //fb('triggered beforePageTransition -- ' + $this.fluidbook.resize.orientation + ' --- REMOVING VIDEOS...'); $this.removeAllVideos(); }); @@ -15,6 +16,25 @@ function FluidbookVideo(fluidbook) { $this.resizeControls(); }); + $(window).on('videoFullscreenEntered', function() { + //fb('>>> Video player entered full screen mode...'); + $this.fullscreenActive = true; + }); + + $(window).on('videoFullscreenExited', function() { + //fb('<<< Video player exited full screen mode.'); + + // Try resizing after a short delay. Depending on the system and the speed of the + setTimeout(function() { + $this.fluidbook.resize.resize(); + }, 250); + + setTimeout(function() { + $this.fullscreenActive = false; // Stop blocking orientation change / page updates + $this.fluidbook.resize.resize(); + }, 1000); + }); + this.fluidbook = fluidbook; @@ -240,6 +260,14 @@ FluidbookVideo.prototype = { // $('#' + player.id()).attr('style', ''); // Reset inline styles // }); + player.on('fullscreenchange', function() { + if (player.isFullscreen()) { + $(window).trigger('videoFullscreenEntered'); + } else { + $(window).trigger('videoFullscreenExited'); + } + }); + }, openVideo: function (link) { if (link === undefined) return false; @@ -372,6 +400,25 @@ FluidbookVideo.prototype = { return players; }, + isVideoFullscreen: function () { + + return this.fullscreenActive; + + // var fullscreenPlayerFound = false; + // + // this.getActivePlayers().forEach(function(p) { + // fb('Video ID: ' + p.id(), 'Fullscreen: ' + p.isFullscreen()); + // + // if (p.isFullscreen()) { + // fullscreenPlayerFound = true; + // return true; + // } + // + // }); + // + // return fullscreenPlayerFound; + }, + resizeControls: function () { // Scale VJS controls size with Fluidbook scale $('.video-js').each(function () { -- 2.39.5