Sas*_*ota 13 java android exoplayer exoplayer2.x
我有一个PlayerView以纵向方式占据活动的上半部分,屏幕的下半部分显示一些文字.
我需要在视频下放置控制器而不重叠视频内容(它将始终显示).默认情况下,当用户触摸视频时,控制器会出现在视频底部,覆盖视频的底部.我的情况我需要控制器粘在视频下面而不与视频内容交叉.
我经历了SimpleExoPlayer和PlayerViewAPI,但我还没有找到任何办法做下去.
问题:如何使用ExoPlayer将控制器置于视频下?
这是布局的样子:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@id/video_view"
android:scrollbars="vertical" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
Pie*_*rre 15
这会将控件下移到屏幕底部:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:use_controller="false" />
<com.google.android.exoplayer2.ui.PlayerControlView
android:id="@+id/controls"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/video_view"
app:show_timeout="0" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
然后在Java中:
PlayerView videoView = findViewById(R.id.video_view);
PlayerControlView controls = findViewById(R.id.controls);
controls.setPlayer(videoView);
Run Code Online (Sandbox Code Playgroud)
编辑:修改了我对@RashimiGautam建议的回答
小智 5
请参阅@Pierre的答案.
同样要从上面删除控制器PlayerView,在这种情况下,@id/video_view通过写入player.showController(false)java文件.
您也可以app:use_controller:false在xml中使用.
所以你将是唯一没有控制器的视频.并将其链接到新控制器,在这种情况下,@id/controls在视频的底部.
| 归档时间: |
|
| 查看次数: |
3113 次 |
| 最近记录: |