kim*_*imv 11 video android fullscreen exoplayer
我有一个使用ExoPlayer播放视频的活动.当我全屏时,除非设备的宽高比等于视频的宽高比,否则我会在视频的顶部和底部看到小的黑条.
这是布局的外观:
<com.google.android.exoplayer.AspectRatioFrameLayout
android:id="@+id/video_frame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true">
<SurfaceView android:id="@+id/surface_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill_vertical"/>
<View android:id="@+id/shutter"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black"/>
</com.google.android.exoplayer.AspectRatioFrameLayout>
Run Code Online (Sandbox Code Playgroud)
我希望如此
aspectRatioFrameLayout.setAspectRatio(mVideo.getAspectRatio());
Run Code Online (Sandbox Code Playgroud)
会解决问题,但我没有成功.有没有办法用视频填充屏幕,即使部分视频是从屏幕上切断的?
Hie*_* Le 13
有一种最快的方式用视频填充屏幕.转至SimpleExoPlayerView.java类,改变resizeMode从AspectRatioFrameLayout.RESIZE_MODE_FIT到AspectRatioFrameLayout.RESIZE_MODE_FILL.
RESIZE_MODE_FILL将忽略指定的宽高比.如果在项目中使用ExoPlayer作为模块,请使用此方法.
更新
如果您使用ExoPlayer作为库,他们有一个方法setResizeMode().你只需AspectRatioFrameLayout.RESIZE_MODE_FILL在你的视图中设置:
simpleExoPlayerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FILL)
这就是全部!
ste*_*ker 10
如果您使用SimpleExoPlayerView.
只需添加app:resize_mode="zoom"以保持视频的纵横比,或者app:resize_mode="fill"如果您不关心纵横比。
<com.google.android.exoplayer2.ui.SimpleExoPlayerView
android:id="@+id/video"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:resize_mode="zoom" />
Run Code Online (Sandbox Code Playgroud)
你可以删除的com.google.android.exoplayer.AspectRatioFrameLayout.
接下来,放一个FrameLayout宽度和高度的简单match_parent.
请注意,SurfaceView应保持宽度和高度= match_parent.
说明:AspectRatioFrameLayout根据实际视频比设置视图的正确高度(根据宽度,高度和pixelRatio计算).如果你不这样做,Exoplayer仍然可以SurfaceView像以前一样在a上显示视图.如果SurfaceView不是@Override它将没有宽高比.
| 归档时间: |
|
| 查看次数: |
13865 次 |
| 最近记录: |