当前仓库属于暂停状态,部分功能使用受限,详情请查阅 仓库状态说明
43 Star 154 Fork 38

江江 / yjPlay
暂停

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
READMELAYUOT.md 10.18 KB
一键复制 编辑 原始数据 按行查看 历史
yangchaojiang 提交于 2018-05-04 20:17 . 修改说明

自定义布局

一.布局使用说明

  1. 布局内容由使用者 任意定义布局
  2. 布局内必须有一个view的id 必须指定
  3. 布局内必须有一个view的id 必须指定
  4. 布局内必须有一个view的id 必须指定

view指定id 说明

  1. 重播布局→ android:id="@id/exo_player_replay_btn_id"
  2. 错误布局→ android:id="@id/exo_player_error_btn_id"
  3. 非wifi播放提示布局→ android:id="@id/exo_player_btn_hint_btn_id"
  4. 加载布局→ android:id="@id/exo_loading_show_text"
  5. 封面图布局——播放按钮指定ID→ android:id="@id/exo_preview_play"
  6. 封面图布局——封面图imageView ID→ android:id="@id/exo_preview_image"

注意:

1.如果指定不指定id 系统不执行相应事件处理
_2.注意加载布局的显示加载速度的控件”exo_loading_show_text“,控件只能是TextView
_3.如果你需要不显示加载网络提示,不指定控件id

二.示例如下

1.-重播布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
    android:background="#80000000"
    android:clickable="true"
    android:gravity="center"
    android:orientation="horizontal"
    >
<!-- 示例该控件指定id>exo_player_replay_btn_id -->
    <ImageView
        android:id="@id/exo_player_replay_btn_id"
        android:layout_width="30dp"
        android:layout_height="30dp"
        app:srcCompat="@drawable/ic_replay_"
        android:textColor="@android:color/white"
        android:layout_marginRight="10dp"
          />

    <ImageView
        android:layout_marginLeft="10dp"
        android:layout_width="30dp"
        android:layout_height="30dp"
        app:srcCompat="@drawable/ic_share"
        android:id="@+id/replay_btn_imageView"
          />
</LinearLayout>

3.-错误布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/exo_error_bg"
    android:clickable="true"
    android:gravity="center"
    android:orientation="vertical">
<!-- 示例该控件指定id>exo_player_error_btn_id -->
    <TextView
        android:id="@id/exo_player_error_btn_id"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:clickable="false"
        android:drawableBottom="@drawable/ic_sentiment_very_dissatisfied_white_48px"
        android:drawablePadding="5dp"
        android:gravity="center"
        android:shadowColor="@color/simple_exo_style_Accent"
        android:text="自定义错误页"
        android:textColor="@android:color/white" />
</LinearLayout>

3.-非wifi播放提示布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/black"
    android:clickable="true"
    android:gravity="center"
    android:orientation="vertical">

<!-- 示例该控件指定id>exo_player_btn_hint_btn_id -->
    <TextView
        android:id="@id/exo_player_btn_hint_btn_id"
        android:layout_width="wrap_content"
        android:layout_height="40dp"
        android:background="@drawable/btn_continue_drawable"
        android:drawablePadding="5dp"
        android:gravity="center"
        android:padding="10dp"
        android:shadowColor="@color/simple_exo_style_Accent"
        android:text="自定义流量提示布局"
        android:textColor="@android:color/white" />
</LinearLayout>

4.-加载布局 动画控件→戳我

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:my="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical"
     >
    <chuangyuan.ycj.videolibrary.widget.ExoVideoAnim
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        my:circleRadius="10dp"
        my:cycle="600" />

    <!--下载速度-->
    <TextView
        android:id="@id/exo_loading_show_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:textColor="@android:color/white"
        android:textSize="16sp" />

</LinearLayout>

三.手势布局自定义布局(布局不需要指定控件id)

1.布局引用

<chuangyuan.ycj.videolibrary.widget.VideoPlayerView
      android:id="@+id/exo_play_context_id"
      android:layout_width="match_parent"
      android:layout_height="200dp"
      app:player_gesture_audio_layout_id="@layout/custom_gesture_audio"
      app:player_gesture_bright_layout_id="@layout/custom_gesture_brightness"
      app:player_gesture_progress_layout_id="@layout/custom_gesture_pro"
      ....
        />

2.代码使用

//实现你手势信息回调接口
  exoPlayerManager.setOnGestureBrightnessListener();//亮度
  exoPlayerManager.setOnGestureProgressListener(); //进度 
  exoPlayerManager.setOnGestureVolumeListener(); //音频
//以下示例代码  
//亮度 
 exoPlayerManager.setOnGestureBrightnessListener(new OnGestureBrightnessListener() {
          @Override
          public void setBrightnessPosition(int mMax, int currIndex) {
              //显示你的布局
              videoPlayerView.getGestureBrightnessLayout().setVisibility(View.VISIBLE);
              //为你布局显示内容自定义内容
              videoBrightnessPro.setMax(mMax);
              videoBrightnessImg.setImageResource(chuangyuan.ycj.videolibrary.R.drawable.ic_brightness_6_white_48px);
              videoBrightnessPro.setProgress(currIndex);
          }
      });
      //进度 
      exoPlayerManager.setOnGestureProgressListener(new OnGestureProgressListener() {
          @Override
          public void showProgressDialog(long seekTimePosition, long duration, String seekTime, String totalTime) {
              //显示你的布局
              videoPlayerView.getGestureProgressLayout().setVisibility(View.VISIBLE);
              exo_video_dialog_pro_text.setTextColor(Color.RED);
              exo_video_dialog_pro_text.setText(seekTime + "/" + totalTime);
          }
          //进度完毕设置
           @Override
            public void endGestureProgress(long position) {
               exoPlayerManager.seekTo(position);
        }
      });
       //音频
      exoPlayerManager.setOnGestureVolumeListener(new OnGestureVolumeListener() {
          @Override
          public void setVolumePosition(int mMax, int currIndex) {
              //显示你的布局
              videoPlayerView.getGestureAudioLayout().setVisibility(View.VISIBLE);
              //为你布局显示内容自定义内容
              videoAudioPro.setMax(mMax);
              videoAudioPro.setProgress(currIndex);
              videoAudioImg.setImageResource(currIndex == 0 ? R.drawable.ic_volume_off_white_48px : R.drawable.ic_volume_up_white_48px);
          }
      });

四. 封面图布局自定义布局(配合使用使用自定义控制布局)

1.布局引用

 <chuangyuan.ycj.videolibrary.widget.VideoPlayerView
        android:id="@+id/exo_play_context_id"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        app:player_preview_layout_id="@layout/exo_default_preview_layout"
        ....
          />

注意:

1.播放按钮指定ID→ android:id="@id/exo_preview_play" 2.封面图imageView ID→ android:id="@id/exo_preview_image"

3.注意事项:

  • 1.你不需要关心手势操作后,布局隐藏问题。自动隐藏布局,专注你需要显示内容就可以了。
  • 2.手势布局可以自定义其中一个或者两个布局。有使用者自己决定需要自定义布局。

五.视频播放进度控件自定义

可以添加属性来自定义视图。可用属性:

name type info
scrubber_drawable reference 设置视频当前播放圆点的自定义资源可以图片
scrubber_color color 设置视频进度圆点的颜色
buffered_color color 设置视频加载缓存进度的颜色
unplayed_color color 设置没有加载过进度的颜色
played_color color 设置已经播放过视频的颜色
ad_marker_color color 使用google广告sdk标记的颜色
played_ad_marker_color color 使用google广告sdk播放后标记的颜色
bar_height dimension 设置视频进度显示高度
touch_target_height dimension 设置 触摸进度条显示的高度(不可用)
ad_marker_width dimension 使用google广告sdk 标记段宽度
scrubber_enabled_size dimension 设置 视频进度条显示右边距大小
scrubber_dragged_size dimension 设置视频进度条显示左边距大小
Android
1
https://gitee.com/yangchaojiang0515/yjPlay.git
git@gitee.com:yangchaojiang0515/yjPlay.git
yangchaojiang0515
yjPlay
yjPlay
master

搜索帮助