Orient live camera feed for best screen fit when in fullscreen mode #16947
+22
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed change
This PR uses the ScreenOrientation.lock() and ScreenOrientation.unlock() APIs to attempt to automatically orient live feeds for individual cameras so that they fill as much screen as possible. This change only applies to fullscreen mode for a single camera, not to the home page or to dashboards which may have more than one camera. If the user changes to a different stream for the same camera while in fullscreen mode and the new stream uses a different aspect ratio, the orientation will update immediately.
Prior discusson on this behavior is in #16925, I'll continue my reasoning here. In my opinion, there are two main reasons to want to enter fullscreen mode when on a mobile device: to de-clutter the interface, and to make the content as large as possible to improve visibility. The existing fullscreen behavior when viewing the feed from a single camera already declutters the UI (hides most buttons, hides system nav bars) but if the video is oriented opposite to your mobile device's screen size, then the content becomes no more visible than it was initially.
There is lots of precedent for locking orientation in video players across mobile devices, including web-based players. Entering fullscreen on most video players will flip the screen orientation to landscape since most videos use a landscape aspect ratio. If the video being played has an aspect ratio that better fits portrait, the player may even flip out of landscape into portrait mode (see YouTube apps on mobile for example).
While the lock()/unlock() APIs are in my opinion the least-invasive way to implement this behavior, they have limited support and will currently only work in Chromium on Android. On other browsers, this change is inert, and the fullscreen view will use the system default orientation that the user was in prior to entering fullscreen mode. To get better cross-browser support and not need to manage the orientation manually, we would probably need to consider calling
requestFullscreen()
on the actual<video>
element rather than an ancestor<div>
. But since there are so many types of video playback in the application and the Live page reuses the same fullscreen element between different views, it seemed prudent to not attempt such a change.Note that I have tested this change on my Android devices, and see it locking orientation on Chromium browsers but not on Firefox for Android (this is expected given API support). I have tested both landscape and portrait video feeds. I do not have an iOS device to test unfortunately, but I expect Safari to also not change behavior with this PR.
Type of change
Additional information
Checklist
ruff format frigate
) (not applicable for JS)