File tree 3 files changed +30
-0
lines changed
3 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,11 @@ declare global {
54
54
interface AudioSession {
55
55
type ?: string ;
56
56
}
57
+ // See https://github.com/microsoft/TypeScript-DOM-lib-generator/issues/1615
58
+ type OrientationLockType = "any" | "landscape" | "landscape-primary" | "landscape-secondary" | "natural" | "portrait" | "portrait-primary" | "portrait-secondary" ;
59
+ interface ScreenOrientation extends EventTarget {
60
+ lock ( orientation : OrientationLockType ) : Promise < void > ;
61
+ }
57
62
}
58
63
59
64
/**
@@ -1005,6 +1010,19 @@ export class InnerPlayer {
1005
1010
* Called when entering / leaving fullscreen.
1006
1011
*/
1007
1012
private fullScreenChange ( ) : void {
1013
+ // If fullScreenAspectRatio is specified properly, lock orientation on mobile when in fullscreen mode
1014
+ if ( this . isFullscreen ) {
1015
+ const fullScreenAspectRatio = this . loadedConfig ?. fullScreenAspectRatio ?. toLowerCase ( ) ?? "" ;
1016
+ if ( fullScreenAspectRatio === "portrait" || fullScreenAspectRatio === "landscape" ) {
1017
+ try {
1018
+ screen . orientation . lock ( fullScreenAspectRatio ) ;
1019
+ } catch { }
1020
+ }
1021
+ } else {
1022
+ try {
1023
+ screen . orientation . unlock ( ) ;
1024
+ } catch { }
1025
+ }
1008
1026
this . instance ?. set_fullscreen ( this . isFullscreen ) ;
1009
1027
}
1010
1028
@@ -2088,6 +2106,10 @@ export function getPolyfillOptions(
2088
2106
if ( wmode !== null ) {
2089
2107
options . wmode = wmode as WindowMode ;
2090
2108
}
2109
+ const fullScreenAspectRatio = getOptionString ( "fullScreenAspectRatio" ) ;
2110
+ if ( fullScreenAspectRatio !== null ) {
2111
+ options . fullScreenAspectRatio = fullScreenAspectRatio ;
2112
+ }
2091
2113
2092
2114
return options ;
2093
2115
}
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ export const DEFAULT_CONFIG: Required<BaseLoadOptions> = {
33
33
menu : true ,
34
34
allowFullscreen : false ,
35
35
salign : "" ,
36
+ fullScreenAspectRatio : "" ,
36
37
forceAlign : false ,
37
38
quality : "high" ,
38
39
scale : "showAll" ,
Original file line number Diff line number Diff line change @@ -492,6 +492,13 @@ export interface BaseLoadOptions {
492
492
*/
493
493
salign ?: string ;
494
494
495
+ /**
496
+ * Controls orientation on mobile in fullscreen mode.
497
+ *
498
+ * @default ""
499
+ */
500
+ fullScreenAspectRatio ?: string ;
501
+
495
502
/**
496
503
* If set to true, movies are prevented from changing the stage alignment.
497
504
*
You can’t perform that action at this time.
0 commit comments