Skip to content

Commit

Permalink
fix(FEC-10510): iOS14 - cannot exit from native PiP by the player's P…
Browse files Browse the repository at this point in the history
…iP button (#483)

* Don't use `exitPictureInPicture` when it's native PiP but use `webkitSetPresentationMode('inline')`
* Remove the redundant `LEAVE_PICTURE_IN_PICTURE` firing. it's already fired natively. 

Solves FEC-10510
  • Loading branch information
yairans authored Oct 19, 2020
1 parent 5822884 commit ddf3a87
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/engines/html5/html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ export default class Html5 extends FakeEventTarget implements IEngine {
// Currently it's supported in chrome and in safari. So if we consider checking support before,
// we can use this flag to distinguish between the two. In the future we might need a different method.
// Second condition is because flow does not support this API yet
if (document.pictureInPictureEnabled && typeof document.exitPictureInPicture === 'function') {
if (document.pictureInPictureEnabled && typeof document.exitPictureInPicture === 'function' && this._el === document.pictureInPictureElement) {
document.exitPictureInPicture().catch(error => {
this.dispatchEvent(
new FakeEvent(
Expand All @@ -544,8 +544,6 @@ export default class Html5 extends FakeEventTarget implements IEngine {
});
} else if (typeof this._el.webkitSetPresentationMode === 'function') {
this._el.webkitSetPresentationMode('inline');
// Safari does not fire this event but Chrome does, normalizing the behaviour
setTimeout(() => this.dispatchEvent(new FakeEvent(Html5EventType.LEAVE_PICTURE_IN_PICTURE)), 0);
}
} catch (error) {
this.dispatchEvent(
Expand Down

0 comments on commit ddf3a87

Please sign in to comment.