]> _ Git - fluidbook-html5.git/commitdiff
Fix #1429 @3.5
authorStephen Cameron <stephen@cubedesigners.com>
Thu, 20 Jul 2017 13:31:53 +0000 (15:31 +0200)
committerStephen Cameron <stephen@cubedesigners.com>
Thu, 20 Jul 2017 13:31:53 +0000 (15:31 +0200)
js/libs/fluidbook/fluidbook.resize.js
js/libs/fluidbook/fluidbook.video.js

index a7400304743fe65a0f19549c005986b898bbd861..1a2172366547e7937fc3abd4870d91de9bc57724 100644 (file)
@@ -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();
index 931e5530f3d303d4b3eae5eab7c43acf56206e43..c6cc5b3267aa1fd7a23689cf617bb3935decf2eb 100644 (file)
@@ -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 () {