我想为播放器制作自定义控制器。在纵向方向上,我将播放器放置在 FrameLayout 中,设置player.setPlayerStyle(YouTubePlayer.PlayerStyle.CHROMELESS)
并在播放器视图上放置自定义视图(使用填充等)。但是如何在全屏模式下执行此操作?
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:id="@+id/yvPlayer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:transitionName="@string/transition_id"
android:visibility="visible" />
<android.support.v7.widget.AppCompatImageView
android:id="@+id/video_play_btn"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_centerInParent="true"
android:clickable="true"
app:srcCompat="@drawable/play_circle"
tools:background="@drawable/play_circle" />
<LinearLayout
android:id="@+id/video_information"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/yvPlayer"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:orientation="horizontal">
<TextView
android:id="@+id/video_current_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="10dp"
android:text="00:01"
android:textColor="@color/white_color" />
<org.adw.library.widgets.discreteseekbar.DiscreteSeekBar
android:id="@+id/video_seekBar"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="10dp"
android:layout_weight="1"
app:dsb_indicatorColor="@color/pink_color"
app:dsb_min="1"
app:dsb_progressColor="@color/pink_color"
app:dsb_rippleColor="@color/pink_color"
app:dsb_trackColor="@color/grey_transparent_color" />
<TextView
android:id="@+id/video_length"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="10dp"
android:text="99:99"
android:textColor="@color/white_color" />
<android.support.v7.widget.AppCompatImageView
android:id="@+id/video_fullscreen"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical|right"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:clickable="true"
app:srcCompat="@drawable/fullscreen" />
</LinearLayout>
</RelativeLayout>
<include
android:id="@+id/video_bar"
layout="@layout/transparent_layout" />
</FrameLayout>
屏幕
@Android答案的补充。
是的,这是正确的。使用"YoutubePlayer.OnFullscreenListener - setFullscreen(boolean)"这是为了通知播放器它正在全屏布局。调用此函数可能会影响播放器控件的外观,从而更改布局以更好地适应当前玩家大小。
调用"YoutubePlayer.OnFullscreenListener"将触发"onFullscreen()事件"。