2016-02-24 71 views
0

我想为播放器制作自定义控制器。在纵向方向上,我将播放器放置在FrameLayout中,设置player.setPlayerStyle(YouTubePlayer.PlayerStyle.CHROMELESS)并在播放器视图上放置自定义视图(使用填充等)。但我怎么能在FullScreenMode中做到这一点?YotubePlayer自定义控制器

<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> 

Screen

+0

只需设置setFullscreen(布尔全屏)。设置了球员风格 – curiousMind

+0

@Android当我设置CHROMLESS风格时,在全屏模式下没有默认控件,我的自定义控件缺席 – Yamko

+0

是的,没有任何默认控件,你必须创建你自己的.please显示你的代码片段你试过了。 – curiousMind

回答

0

加成@ Android的答案。

是的,它是正确的。使用'YoutubePlayer.OnFullscreenListener - setFullscreen(boolean)'这是为了通知玩家它正在全屏布局。调用此函数可能会影响播放器控件的外观,更改布局以更好地适应当前播放器的尺寸。

调用'YoutubePlayer.OnFullscreenListener'将触发'onFullscreen()事件。