Merged logic for orientation and status bar

This commit is contained in:
WardPearce
2025-01-23 18:38:12 +13:00
parent c8c23c7b1f
commit 5a31383d78
2 changed files with 17 additions and 9 deletions
+17 -8
View File
@@ -410,23 +410,32 @@
}
if (Capacitor.getPlatform() === 'android') {
let initialFullscreen = true;
const videoFormats = data.video.adaptiveFormats.filter((format) =>
format.type.startsWith('video/')
);
originalOrigination = await ScreenOrientation.orientation();
player.addEventListener('fullscreen-change', async (event: FullscreenChangeEvent) => {
// A bit of a hack to fix Android automatically
// fullscreening when opening a video.
if (initialFullscreen) {
player.exitFullscreen();
initialFullscreen = false;
return;
}
if (event.detail) {
// Ensure bar color is black while in fullscreen
await StatusBar.setBackgroundColor({ color: '#000000' });
} else {
await setStatusBarColor();
}
});
}
if (get(playerAndroidLockOrientation)) {
const videoFormats = data.video.adaptiveFormats.filter((format) =>
format.type.startsWith('video/')
);
if (!get(playerAndroidLockOrientation)) return;
originalOrigination = await ScreenOrientation.orientation();
player.addEventListener('fullscreen-change', async (event: FullscreenChangeEvent) => {
if (event.detail && videoFormats[0].resolution) {
const widthHeight = videoFormats[0].resolution.split('x');
-1
View File
@@ -292,7 +292,6 @@ export function ensureNoTrailingSlash(url: any): string {
return url.endsWith('/') ? url.slice(0, -1) : url;
}
export async function setStatusBarColor() {
if (Capacitor.getPlatform() === 'android') {
await StatusBar.setBackgroundColor({