在android开发中,视频的播放一般会使用VideoView来处理,但是现在流行一款开源框架即Vitamio,用它可以打造自己开源的个性化播放器,先给大家放上一个参考连接
http://06.hk/Android/71750.html#
最近项目中开始也用的是VideoView,后来换成了Vitamio,加上了根据手势滑动快进或后退,上下滑动调整音量的效果。。先上两张图
原理其实比较简单。。主要是通过在代码中对布局中view控制显隐来实现,同时同步io.vov.vitamio.widget.VideoView的信息即可
布局文件
<?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" android:orientation="vertical" > <io.vov.vitamio.widget.VideoView android:id="@+id/surface_view" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_centerHorizontal="true" android:layout_centerVertical="true" /> <RelativeLayout android:id="@+id/gesture_volume_layout" android:layout_width="120dip" android:layout_height="120dip" android:layout_centerInParent="true" android:background="@drawable/souhu_player_gesture_bg" android:gravity="center" android:visibility="invisible" > <ImageView android:id="@+id/gesture_iv_player_volume" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:src="@drawable/souhu_player_volume" /> <TextView android:id="@+id/geture_tv_volume_percentage" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/gesture_iv_player_volume" android:layout_centerHorizontal="true" android:gravity="right" android:text="80%" android:textColor="#ffececec" /> </RelativeLayout> <RelativeLayout android:id="@+id/gesture_progress_layout" android:layout_width="120dip" android:layout_height="80dip" android:layout_centerInParent="true" android:background="@drawable/souhu_player_gesture_bg" android:gravity="center" android:visibility="invisible" > <ImageView android:id="@+id/gesture_iv_progress" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:src="@drawable/souhu_player_backward" /> <TextView android:id="@+id/geture_tv_progress_time" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/gesture_iv_progress" android:layout_centerHorizontal="true" android:gravity="right" android:text="00:35/24:89" android:textColor="#ffececec" /> </RelativeLayout> </RelativeLayout>
具体的处理我传到资源里面了。。有详细的说明 :别忘了在SD卡根目录下放一个mp4来做测试
资源的地址http://download.csdn.net/detail/yaya_soft/7129941