Repository navigation
aosp: Apply the player bounds to the video surface - #13282
Conversation
|
🤖 Gemini Suggested Commit Message💡 Pro Tips for a Better Commit Message:
|
There was a problem hiding this comment.
Code Review
This pull request updates MainActivity to store a reference to VideoSurfaceView and implements setVideoSurfaceBounds to dynamically resize and reposition the video surface on the UI thread. The review feedback highlights a potential race condition in setVideoSurfaceBounds where mVideoSurfaceView might be null when the UI thread runnable executes, and suggests adding a null check to prevent a NullPointerException.
andrewsavage1
left a comment
There was a problem hiding this comment.
Note we'll also need to implement resetVideoSurface either here or in a follow-up
Done. PTAL at latest change |
BaseCobaltActivity.setVideoSurfaceBounds() did nothing on AOSP, so the video always filled the screen, whatever the player's bounds. For example, Shorts showed a cropped video. Move and resize the VideoSurfaceView to the player bounds, as Android TV does. Test: Shorts now play in their 608x1080 frame. A 640x360 video element at 200,150 gets a video layer with the same bounds, and the layer follows when the element moves. Before, it stayed full screen. Fixed: 567316237
2e63b62 to
c1ea72d
Compare
andrewsavage1
left a comment
There was a problem hiding this comment.
One follow-up on the onStart() / onStop() video surface lifecycle handling in CobaltActivity:
CobaltActivity still has two pieces of mVideoSurfaceView logic in onStart() and onStop() that weren't moved to BaseCobaltActivity:
- Recreating the surface on start if it wasn't destroyed when stopped (
mForceCreateNewVideoSurfaceViewinonStop()/onStart()). - Resetting the video surface bounds to fullscreen in
onStop():View rootView = getWindow().getDecorView(); setVideoSurfaceBounds(0, 0, rootView.getWidth(), rootView.getHeight());
We probably want to move those into BaseCobaltActivity.onStart() / onStop() as well (probably in a follow-up) so AOSP gets the same behavior when backgrounding/resuming
Agreed. I can work on it in a follow-up PR. PLMK if that's reasonable. |
LGTM w/ a +1 to this |
…face Refer to original PR: #13282 BaseCobaltActivity.setVideoSurfaceBounds() did nothing on AOSP, so the video always filled the screen, whatever the player's bounds. For example, Shorts showed a cropped video. Move Android TV's video surface code from CobaltActivity into BaseCobaltActivity, so AOSP uses it too. That covers both setVideoSurfaceBounds() and resetVideoSurface(). Test: Shorts now play in their 608x1080 frame. A 640x360 video element at 200,150 gets a video layer with the same bounds, and the layer follows when the element moves. Before, it stayed full screen. The Android TV Java library builds. Fixed: 567316237 (cherry picked from commit 2e63208)
…face Refer to original PR: #13282 BaseCobaltActivity.setVideoSurfaceBounds() did nothing on AOSP, so the video always filled the screen, whatever the player's bounds. For example, Shorts showed a cropped video. Move Android TV's video surface code from CobaltActivity into BaseCobaltActivity, so AOSP uses it too. That covers both setVideoSurfaceBounds() and resetVideoSurface(). Test: Shorts now play in their 608x1080 frame. A 640x360 video element at 200,150 gets a video layer with the same bounds, and the layer follows when the element moves. Before, it stayed full screen. The Android TV Java library builds. Fixed: 567316237 (cherry picked from commit 2e63208)
…face Refer to original PR: #13282 BaseCobaltActivity.setVideoSurfaceBounds() did nothing on AOSP, so the video always filled the screen, whatever the player's bounds. For example, Shorts showed a cropped video. Move Android TV's video surface code from CobaltActivity into BaseCobaltActivity, so AOSP uses it too. That covers both setVideoSurfaceBounds() and resetVideoSurface(). Test: Shorts now play in their 608x1080 frame. A 640x360 video element at 200,150 gets a video layer with the same bounds, and the layer follows when the element moves. Before, it stayed full screen. The Android TV Java library builds. Fixed: 567316237 (cherry picked from commit 2e63208)
BaseCobaltActivity.setVideoSurfaceBounds() did nothing on AOSP, so the
video always filled the screen, whatever the player's bounds. For
example, Shorts showed a cropped video.
Move Android TV's video surface code from CobaltActivity into
BaseCobaltActivity, so AOSP uses it too. That covers both
setVideoSurfaceBounds() and resetVideoSurface().
Test: Shorts now play in their 608x1080 frame. A 640x360 video
element at 200,150 gets a video layer with the same bounds, and the
layer follows when the element moves. Before, it stayed full screen.
The Android TV Java library builds.
Fixed: 567316237