很久没更新博客,相信大家年后都比较忙。
今天给大家带来了一款视频播放器,首先确认的得有几点。
1、首先得有个播放视频的view;
2、加点额外功能进去左边上下滑动调节亮度,右边上下滑动调节声量;
3、视频当然得有快进和快退,左右滑动快进和快退;
4、可全屏播放;
5、暂时只做了离线播放。下篇博客再去研究在线播放。视频路径 这是视频本地路径,视频资源的话你们自己去找,文件夹会自动创建,放在该文件夹下面就可以了
private String Path = Environment.getExternalStorageDirectory() + “/wywVideo/
首先先贴上效果图:
咱们根据效果图一步一步的来,先进行布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.wyw.activity.FullVideoView
android:id="@+id/video_VideoView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ImageView
android:id="@+id/video_img"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<ImageView
android:id="@+id/video_img_center_speed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
/>
<RelativeLayout
android:id="@+id/video_relative_right"
android:layout_width="300dp"
android:layout_height="match_parent"
android:layout_above="@+id/video_relative_buttom"
android:layout_alignParentRight="true"
android:background="@color/lightgray_50" >
<ImageView
android:id="@+id/video_imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:src="@drawable/right_video_img" />
<ListView
android:id="@+id/video_listview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/video_imageView"
android:paddingRight="10dp" >
</ListView>
</RelativeLayout>
<RelativeLayout
android:id="@+id/video_relative_buttom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:background="@color/gray_50" >
<ImageView
android:id="@+id/video_img_last"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_centerVertical="true"
android:src="@drawable/last_video_selector" />
<ImageView
android:id="@+id/video_img_start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/video_img_last"
android:src="@drawable/start_video_df" />
<ImageView
android:id="@+id/video_img_next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/video_img_start"
android:src="@drawable/next_video_selector" />
<ImageView
android:id="@+id/video_img_voice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/video_img_full"
android:src="@drawable/right_show_img" />
<ImageView
android:id="@+id/video_img_full"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="30dp"
android:src="@drawable/big_video_selector" />
<TextView
android:id="@+id/video_txt_current_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@+id/video_img_next"
android:text="@string/play_time"
android:textColor="@color/white" />
<ImageView
android:id="@+id/video_videoview_pres_bg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_toLeftOf="@+id/video_txt_max_time"
android:layout_toRightOf="@+id/video_txt_current_time"
android:background=