You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Screen orientation lock not working (eg. portrait-primary) if the device is locked in other orientation (eg. landscape-primary) but held in the first orientation (eg. portrait-primary)
#82
Hello, I have an application which plays live streams. Because we want custom controls on iOS we can't use the fullscreen API from our player, so we need to mimic it by using css. When the user hits a button the app is locked to landscape and the css changes for fullscreen view. The other way around for exit fullscreen.
Problem
The screen orientation works perfect on Android, but not for iOS.
What is expected to happen?
The application should change its orientation as the call to screenOrientation.lock is made.
What does actually happen?
If the phone is HELD in the same orientation everything works as expected, even on iOS.
But if the following steps are done:
the phone is held in portrait (locked)
user hits fullscreen => app locks to landscape and everything looks good
the user turns the phone to landscape then back to portrait (the app is still in landscape, being locked)
the user hits the exit fullscreen button which should lock the phone to portrait => the phone remains in landscape (100% of the cases). Here is the even stranger part, if the user turns the phone in any landscape mode the app goes in portrait and it is locked there. It seems that somehow the phone realizes it is not in portrait only after the user rotates the phone and then it changes to portrait, as already mentioned.
Information
The code runs without any issues, no warnings, no errors, logs from within the lock promise are displayed, everything seems fine, the phone does not change its orientation.
Command or Code
import {ScreenOrientation} from '@ionic-native/screen-orientation/ngx';
constructor(private screenOrientation: ScreenOrientation) {
this.orientation = this.screenOrientation.type;
this.screenOrientation.onChange().subscribe(() => {
if (this.orientation !== this.screenOrientation.type) {
this.orientation = this.screenOrientation.type;
this.orientationChangeSubject.next(this.screenOrientation.type);
}
});
}
private changeTo(orientation, unlock: boolean = true): Promise<void> {
return this.screenOrientation.lock(orientation).then(() => {
this.orientation = orientation;
if (unlock) {
this.unlock();
}
}).catch(() =>
console.error('The fullscreen button does not work from the browser, only from mobile devices')
);
}
// The "changeTo " method is called like this:
changeToPortraitAndLock() {
return this.changeTo(this.screenOrientation.ORIENTATIONS.PORTRAIT_PRIMARY, false);
}
ghost
changed the title
Screen orientation not working randomly
Screen orientation lock not working (eg. portrait-primary) if the device is locked in other orientation (eg. landscape-primary) but held in the first orientation (eg. portrait-primary))
Jul 29, 2021
ghost
changed the title
Screen orientation lock not working (eg. portrait-primary) if the device is locked in other orientation (eg. landscape-primary) but held in the first orientation (eg. portrait-primary))
Screen orientation lock not working (eg. portrait-primary) if the device is locked in other orientation (eg. landscape-primary) but held in the first orientation (eg. portrait-primary)
Jul 29, 2021
Bug Report
Hello, I have an application which plays live streams. Because we want custom controls on iOS we can't use the fullscreen API from our player, so we need to mimic it by using css. When the user hits a button the app is locked to landscape and the css changes for fullscreen view. The other way around for exit fullscreen.
Problem
The screen orientation works perfect on Android, but not for iOS.
What is expected to happen?
The application should change its orientation as the call to screenOrientation.lock is made.
What does actually happen?
If the phone is HELD in the same orientation everything works as expected, even on iOS.
But if the following steps are done:
Information
The code runs without any issues, no warnings, no errors, logs from within the lock promise are displayed, everything seems fine, the phone does not change its orientation.
Command or Code
Environment, Platform, Device
iOS 14.3
Version information
Checklist
The text was updated successfully, but these errors were encountered: