我想为播放器制作自定义控制器。在纵向方向上,我将玩家放在FrameLayout中,设置player.setPlayerStyle(YouTubePlayer.PlayerStyle.CHROMELESS)
并在玩家视图上放置自定义视图(使用填充等)。但是我怎么能在FullScreenMode中做到这一点?
<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>
答案 0 :(得分:0)
除了@Anroid&#39的回答。
是的,这是对的。使用'YoutubePlayer.OnFullscreenListener - setFullscreen(boolean)'这是为了通知播放器它是全屏布局的。调用此功能可能会影响播放器控件的外观,更改布局以更好地适应当前播放器的大小。
调用&#39; YoutubePlayer.OnFullscreenListener&#39;将触发&#39; onFullscreen()事件。