mirror of
				https://github.com/videojs/video.js.git
				synced 2025-10-31 00:08:01 +02:00 
			
		
		
		
	fix: Don't request fullscreen from document PIP window (#8881)
## Description Double clicking the document pip window requests fullscreen but this fails. The gesture on the pip window can't initiate fullscreen. Fixes #8877 ## Specific Changes proposed Change the default double click action to just exit pip. This is the same behaviour as before without the error, as requestFullScreen() calls exitPictureInPicture(); --------- Co-authored-by: Gary Katsevman <git@gkatsev.com>
This commit is contained in:
		| @@ -2003,7 +2003,8 @@ class Player extends Component { | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Handle a double-click on the media element to enter/exit fullscreen | ||||
|    * Handle a double-click on the media element to enter/exit fullscreen, | ||||
|    * or exit documentPictureInPicture mode | ||||
|    * | ||||
|    * @param {Event} event | ||||
|    *        the event that caused this function to trigger | ||||
| @@ -2045,7 +2046,12 @@ class Player extends Component { | ||||
|         ) { | ||||
|  | ||||
|           this.options_.userActions.doubleClick.call(this, event); | ||||
|  | ||||
|         } else if (this.isInPictureInPicture() && !document.pictureInPictureElement) { | ||||
|           // Checking the presence of `window.documentPictureInPicture.window` complicates | ||||
|           // tests, checking `document.pictureInPictureElement` also works. It wouldn't | ||||
|           // be null in regular picture in picture. | ||||
|           // Exit picture in picture mode. This gesture can't trigger pip on the main window. | ||||
|           this.exitPictureInPicture(); | ||||
|         } else if (this.isFullscreen()) { | ||||
|           this.exitFullscreen(); | ||||
|         } else { | ||||
|   | ||||
| @@ -151,6 +151,19 @@ QUnit.test('by default, double-click opens fullscreen', function(assert) { | ||||
|   assert.strictEqual(this.player.exitFullscreen.callCount, 1, 'has exited fullscreen'); | ||||
| }); | ||||
|  | ||||
| QUnit.test('in document picture in picture mode, double-click exits pip', function(assert) { | ||||
|   this.player.isInPictureInPicture = () => true; | ||||
|   this.player.exitPictureInPicture = sinon.spy(); | ||||
|   this.player.requestFullscreen = sinon.spy(); | ||||
|   this.player.exitFullscreen = sinon.spy(); | ||||
|  | ||||
|   this.player.handleTechDoubleClick_({target: this.player.tech_.el_}); | ||||
|  | ||||
|   assert.strictEqual(this.player.exitPictureInPicture.callCount, 1, 'has exited pip once'); | ||||
|   assert.strictEqual(this.player.requestFullscreen.callCount, 0, 'has not entered fullscreen'); | ||||
|   assert.strictEqual(this.player.exitFullscreen.callCount, 0, 'has not exited fullscreen'); | ||||
| }); | ||||
|  | ||||
| QUnit.test('when controls are disabled, double-click does nothing', function(assert) { | ||||
|   let fullscreen = false; | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user