android 自定义视频播放器之2/1

本文介绍如何创建一个自定义的Android视频播放器,具备调节亮度和音量、快进快退、全屏播放等功能。详细讲解了手势识别、进度条动态显示以及时间跳转的实现,并提供了数据Bean和适配器的代码片段。下篇博客将探讨在线播放和解码技术。
摘要由CSDN通过智能技术生成

很久没更新博客,相信大家年后都比较忙。
今天给大家带来了一款视频播放器,首先确认的得有几点。
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=
评论 16
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值