javascript - changing screen orientation in a Chrome PWA - Stack Overflow

I built a Progressive Web Application (PWA) that specifies "orientation": "portrait"

I built a Progressive Web Application (PWA) that specifies "orientation": "portrait" in it's Manifest file.

This ensures that the application is displayed in portrait mode no matter how the phone is held (at least with Chrome).

This is fine for nearly all situations for my application, but there are situations where an embedded YouTube video is shown (iframe embedding API). When placing the video into fullscreen mode, the video is displayed in portrait mode, which is not useful.

Can I change the desired screen orientation via JavaScript? Or at least "unlock" the orientation so that the manifest setting is temporarily disabled?

I built a Progressive Web Application (PWA) that specifies "orientation": "portrait" in it's Manifest file.

This ensures that the application is displayed in portrait mode no matter how the phone is held (at least with Chrome).

This is fine for nearly all situations for my application, but there are situations where an embedded YouTube video is shown (iframe embedding API). When placing the video into fullscreen mode, the video is displayed in portrait mode, which is not useful.

Can I change the desired screen orientation via JavaScript? Or at least "unlock" the orientation so that the manifest setting is temporarily disabled?

Share edited Mar 19, 2023 at 11:21 Walter Monroe 3201 silver badge11 bronze badges asked Apr 2, 2017 at 16:16 Udo GUdo G 13.2k16 gold badges63 silver badges92 bronze badges 2
  • Have similar problem with fullscreen video in a PWA. Did you find any solution yet? – t1gor Commented Jul 8, 2019 at 7:53
  • nope, unfortunately – Udo G Commented Jul 8, 2019 at 11:38
Add a ment  | 

1 Answer 1

Reset to default 4

What we ended up doing is removing "orientation" property pletely from manifest.json. That would allow full screen video with rotations. I guess if you really want to leave only "portrait" orientation in the rest of the app, you can lock it with JS using the screen.orientation API: https://caniuse./#feat=screen-orientation (81.82% supported):

// to lock portrait
ScreenOrientation.lock("portrait");

// and then allow any
ScreenOrientation.unlock();

Please note, that this is still a working draft, not a live spec. Some more docs and info from Mozilla. Hope that helps.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744911599a4600586.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信