Exoplayer Surfaceview Aspect Ratio, Jul 29, 2020 · It works wi
Exoplayer Surfaceview Aspect Ratio, Jul 29, 2020 · It works with TextureView, SurfaceView, and ExoPlayer’s own PlayerView. TextureView. Does anybody know if there is a way of solving this without having to rotate the video using re-encoding? Oct 20, 2025 · The biggest difference between the implementations are the steps required to present the correct aspect ratio. So set height to maximum and crop on both sides. setResizeMode(AspectRatioFrameLayout. Mux Player supports: * on-demand assets * live streams * low-latency live streams * DVR mode for . The ZoomLayout engine provides really great features to zoom and pan to certain portions of the video. I tried it, but if I use raw TextureView instead of SimpleExoPlayer, I can't benefit from ExoPlayer's advantages, such as playback controls, fixed aspect ratio etc. * Nov 9, 2015 · 社区首页 > 问答首页 > 在Android中,使用exoplayer,如何用与设备宽高比不同的视频填充surfaceview? 问 在Android中,使用exoplayer,如何用与设备宽高比不同的视频填充surfaceview? Dec 11, 2014 · I am playing video from my server on surface using texture view, but its stretching the video and not able maintain aspect ratio of video. setRotation(), but it doesn't affect the video. RESIZE_MODE_FILL); 以下代码将确保4:3视频的长宽比得到正确维护。 exoPlayer. I tried to use /** * The height is fixed and the width is increased or decreased to obtain the desired aspect ratio. fill the view with the video. Create and initialize a Oct 4, 2016 · With MediaPlayer in the onPrepared () method I use getVideoWidth () and getVideoHeight () to get width and height of video to calculate size of SurfaceView with correct aspect ratio. On Android, it uses ExoPlayer. Jul 3, 2021 · ExoPlayer does provide an option to zoom via the included AspectRatioFrameLayout but without an option to pan. On newer Android versions, you also hit platform quirks around SurfaceView inside Compose — which the Media3 team has had to work around in their own UI modules. Feb 26, 2018 · I am playing video from URL on Exoplayer, it stretching the video on resizing/on using resize_mode as I have mentioned in layout file using this I am not able to maintain the aspect ratio of video. RESIZE_MODE_FIT looks at aspectDeformation = videoAspectRatio / viewAspectRatio - 1 to decide whether to shrink width or height. This recipe demonstrates how to use the video_player package to stream a video from the internet with basic play and pause controls using the following steps: Add the video_player dependency. setRotation() works fine, but the video is rendered in 1080p instead of 4K (which is expected according to the documentation). Non-uniform scaling by TextureView transformation matrix to obtain the original video (rotated) aspect which does the necessary cropping too - in PlayerView. e. Apr 8, 2016 · Note that if you're using AspectRatioFrameLayout or similar then the scaling mode isn't going to make a difference; the difference will only be apparent if the SurfaceView has a different aspect ratio to the video. 将SurfaceView放置到容器 (FrameLayout)中,该容器的大小将被更改: android:id="@+id/rootView" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/colorBlack" android:focusable="true" android:keepScreenOn="true"> <FrameLayout. </SYSTEM> # Mux Player for web Mux Player is a drop in component for adding Mux videos into your web application **Mux Player** is a drop-in component that you can put in your web application to play Mux assets. Mar 14, 2024 · The OP was also struggling with RESIZE_MODE_FIT and I documented above as to why the scaling is dependent on the video aspect ratio AND the phone size. I am not familiar with the source and am wondering exoVideoPlayerView. If a user goes to full screen in portrait mode and updateVideoViewMatchToParent() is called, then both the BaseVideoView and SurfaceView will fill the device’s display and the video aspect ratio will be slightly modified. Should I code those features myself if I choose to use TextureView? ExoPlayer layout with fixed aspect ratio Asked 7 years, 11 months ago Modified 6 years, 8 months ago Viewed 14k times Jun 16, 2021 · Using VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING makes no difference. Scaling SurfaceView requires a custom implementation of FrameLayout. On iOS, the video_player plugin makes use of AVPlayer to handle playback. Nov 19, 2025 · Layout concerns like aspect ratio and cropping are defined in the View world (RESIZE_MODE_*), not in terms of Modifier and ContentScale. Nov 9, 2015 · I have an activity that uses ExoPlayer to play a video. Keeping in mind that I use android:screenOrientation="sensorLandscape" in AndroidManifest for the Activity that contains ExoPlayer in my project, here is the way that I used for changing the aspect ratio of SurfaceView according to aspect ratio of the video. 0-beta01 Devices that reproduce the issue Any device or emulator running Android 14 Devices The aspect ratio will be modified slightly. android. RESIZE_MODE_FIT); 您还可以尝试在 exoplayer 中更改 VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING - Sagar Nov 24, 2016 · Customizing ExoPlayer’s UI components ExoPlayer V2 includes several out-of-the-box UI components, most notably: PlaybackControlView is a view for controlling ExoPlayer instances. Jun 2, 2020 · Basically I need to display 16:9 movie to fullscreen on 19:10 screen. exoplayer2. The aspect ratio will be modified slightly. AspectRatioFrameLayout Apr 2, 2024 · I have faced exact same issue, except I was using resizeMode with fixed height. When I go fullscreen, unless the aspect ratio of the device is equal to that of the video, I get small black bars at the top and the bottom of the video. <SYSTEM>This is the developer documentation for Mux Player for Web, iOS, and Android. Jan 12, 2016 · Change the aspect ratio of surface view according to aspect ratio of the video in exoplayer demo application Asked 9 years, 3 months ago Modified 8 years, 2 months ago Viewed 7k times 10 I am currently using Exoplayer in a project and am looking to achieve a "CenterCrop" type attribute similar on the video to what you might see in an imageview. This page shows Java code examples of com. 下面是我用于根据视频宽高比更改SurfaceView宽高比的方法。 1. applyTextureViewRotation - again to be investigated how to modify outside of ExoPlayer sources: Dec 18, 2015 · You probably don't want to use AspectRatioFrameLayout in conjunction with this parameter. But, I wish to maintain aspect ratio as per the video as i Apr 10, 2019 · How to make ExoPlayer compatible with all type video aspect ratios? Asked 5 years, 11 months ago Modified 5 years, 11 months ago Viewed 781 times Oct 17, 2022 · I tried using SurfaceView. Oct 30, 2025 · How to use the video_player plugin. I addition I have noticed that the video gets right aspect ratio after I switched orientation to landscape and then back to portrait. Basically it will fit to the height of the surfaceview, keep the same aspect ratio, and crop the edges on the side that go off the screen. ui. It might make more sense to use SurfaceView directly, or alternatively use AspectRatioFrameLayout but set the ratio based on the desired ratio of the view, not the ratio of the video. 1 More version details Reproduced also in latest version of Exoplayer, and Media3 1. Mar 25, 2018 · Kyle Venn, thank you for your answer. Add permissions to your app. 2. The first two choices require fine graining details about position, size, and aspect ratio. Oct 17, 2018 · Resize view to fit aspect ratio of video in Android ExoPlayer Been playing with ExoPlayer in Android and trying to resize a view to fit the aspect ratio of the video being played, i. 3. My layout looks something like this: Mar 25, 2018 · Kyle Venn, thank you for your answer. google. Feb 22, 2024 · Version Media3 1. Should I code those features myself if I choose to use TextureView? Dec 8, 2018 · I have the requirement that videos should be cropped to not exceed some minimum aspect ratio (say 9:16) and some maximum aspect ratio (say 16:9). 3d8q, njrh, zskc4, bww6h, naq1, ncr5, 0ifap2, bttbo, rbm5, zbamp,