Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): Fix iOS fullscreen on rotation #4679

Merged
merged 6 commits into from
Dec 6, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: remove three nested try/catch blocks
ocipap committed Nov 21, 2022
commit de5e0ffad9052c14adf33f610ad0b5f4bd9a43fc
30 changes: 11 additions & 19 deletions ui/controls.js
Original file line number Diff line number Diff line change
@@ -591,25 +591,15 @@ shaka.ui.Controls = class extends shaka.util.FakeEventTarget {
async enterFullScreen_() {
try {
if (document.fullscreenEnabled) {
try {
if (document.pictureInPictureElement) {
await document.exitPictureInPicture();
}
await this.videoContainer_.requestFullscreen({navigationUI: 'hide'});

if (this.config_.forceLandscapeOnFullscreen && screen.orientation) {
try {
// Locking to 'landscape' should let it be either
// 'landscape-primary' or 'landscape-secondary' as appropriate.
await screen.orientation.lock('landscape');
} catch (error) {
// If screen.orientation.lock does not work on a device, it will
// be rejected with an error. Suppress that error.
}
}
} catch (error) {
this.dispatchEvent(new shaka.util.FakeEvent(
'error', (new Map()).set('detail', error)));
if (document.pictureInPictureElement) {
await document.exitPictureInPicture();
}
await this.videoContainer_.requestFullscreen({navigationUI: 'hide'});

if (this.config_.forceLandscapeOnFullscreen && screen.orientation) {
// Locking to 'landscape' should let it be either
// 'landscape-primary' or 'landscape-secondary' as appropriate.
await screen.orientation.lock('landscape');
}
} else {
const video = /** @type {HTMLVideoElement} */(this.localVideo_);
@@ -618,6 +608,8 @@ shaka.ui.Controls = class extends shaka.util.FakeEventTarget {
}
}
} catch (error) {
joeyparrish marked this conversation as resolved.
Show resolved Hide resolved
this.dispatchEvent(new shaka.util.FakeEvent(
'error', (new Map()).set('detail', error)));
// Entering fullscreen can fail
// if the user didn't interacting with the video.
// be rejected with an error. Suppress that error.