androidx / media

Jetpack Media3 support libraries for media use cases, including ExoPlayer, an extensible media player for Android
https://developer.android.com/media/media3
Apache License 2.0
1.72k stars 413 forks source link

Request: when using VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING, also offer a way to pan #1864

Open AndroidDeveloperLB opened 2 weeks ago

AndroidDeveloperLB commented 2 weeks ago

[REQUIRED] Use case description

I wanted to add panning of video playback inside a live wallpaper, so that when the user scrolls horizontally/vertically (using onOffsetsChanged) in case the video doesn't fit perfectly in the resolution of the device, it will move so that you could see the rest of the video content. This repository has just that, of playing video using ExoPlayer into a live wallpaper:

https://github.com/linlukes/VideoLiveWallpaper

Proposed solution

Maybe have a function "setPanningInPercentage(xPercentage:Double, yPercentage:Double)", where 0.5 is the center for both. Can also be done in other units. I think it might be nice to have Matrix being offered as well. If this is possible, please let me know how to use it in this scenario, of what should be the values being used.

Alternatives considered

I thought that maybe for this specific case, I could use setImageOutput of ExoPlayer, and each time I get a Bitmap, I could use the Canvas of the live wallpaper and move it accordingly, but I think this is too CPU intensive, making the playing not smooth at all.