Vitamio视频播放

activity代码

package com.hck.player.ui;

import io.vov.utils.StringUtils;
import io.vov.vitamio.LibsChecker;
import io.vov.vitamio.MediaPlayer;
import io.vov.vitamio.MediaPlayer.OnBufferingUpdateListener;
import io.vov.vitamio.MediaPlayer.OnCompletionListener;
import io.vov.vitamio.MediaPlayer.OnErrorListener;
import io.vov.vitamio.MediaPlayer.OnInfoListener;
import io.vov.vitamio.MediaPlayer.OnPreparedListener;
import io.vov.vitamio.MediaPlayer.OnSeekCompleteListener;
import io.vov.vitamio.MediaPlayer.OnVideoSizeChangedListener;
import io.vov.vitamio.widget.VideoView;

import java.sql.Timestamp;
import java.util.ArrayList;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.graphics.Color;
import android.media.AudioManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.Display;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;

import com.hck.myplayer.R;
import com.zdp.aseo.content.AseoZdpAseo;

public class PlayActivity extends BaseActivity implements OnClickListener,
        OnBufferingUpdateListener, OnCompletionListener, OnPreparedListener,
        OnVideoSizeChangedListener, SurfaceHolder.Callback, OnErrorListener,
        OnInfoListener, OnSeekCompleteListener {
    private String path;
    private ImageView imageView;
    private TextView nametTextView;
    private TextView timeTextView;
    private Button chiceButton;
    private Button fontbButton, playbButton, nextButton;
    private VideoView videoView;
    private FrameLayout fLayout;
    private LinearLayout layout;
    private boolean isPlay;
    private SeekBar seekBar;
    private upDateSeekBar update;
    private boolean isLock;
    private String timeString;
    private TextView play_tiem, endTime;
    private String name;
    private ImageView mOperationBg;
    private ImageView mOperationPercent;
    private View mVolumeBrightnessLayout;
    private AudioManager mAudioManager;
    /** 最大声音 */
    private int mMaxVolume;
    /** 当前声音 */
    private int mVolume = -1;
     /** 当前亮度 */
    private float mBrightness = -1f;
    private GestureDetector mGestureDetector;
    private View bar;
    private TextView textViewBF;
    private TextView sudu;
    private TextView sudu2;
    private PopupWindow pWindow;
    private Button qingxiButton, liuchangButton, gaoqingButton;

    private boolean isFinish;
    private long pauseSize;
    private long size;
    private ArrayList<String> urls;
    private static int flag;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // 检测Vitamio是否解压解码包
        if (!LibsChecker.checkVitamioLibs(this))
            return;
        // 去除标题栏
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        // 设置为全屏
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        // 定义布局
        setContentView(R.layout.play);
        // 初始化布局
        initView();
        // 获得数据
        getInitDate();
        // 设置数据
        setInitDate();
        nextButton.setEnabled(false);
        fontbButton.setEnabled(false);
        play();
        AseoZdpAseo.initType(this, AseoZdpAseo.INSERT_TYPE);

    }

    private void getInitDate() {
        // path = getIntent().getStringExtra("path");
        // 获取视频的名称
        name = getIntent().getStringExtra("name");
        // 获取视频的url
        urls = getIntent().getStringArrayListExtra("url");

    }

    private void setInitDate() {
        // 设置视频的名称,并显示在屏幕上
        nametTextView.setText("视频名字:" + name);
    }

    private void initView() {
        // 地址集合
        urls = new ArrayList<String>();
        // 视频播放进度条
        seekBar = (SeekBar) findViewById(R.id.seekBar);
        // 视频信息 ,设置为不可见
        fLayout = (FrameLayout) findViewById(R.id.title_fl);
        fLayout.setVisibility(View.GONE);
        // 视频屏幕下方的控制菜单,设置为不可见
        layout = (LinearLayout) findViewById(R.id.buttom_lin);
        layout.setVisibility(View.GONE);
        // 视频播放框
        videoView = (VideoView) findViewById(R.id.surface_view);
        // 屏幕是否解锁,并设置不可见,实现监听
        imageView = (ImageView) findViewById(R.id.image_lock);
        imageView.setOnClickListener(this);
        imageView.setVisibility(View.GONE);
        // 视频下载的速度kb/s
        sudu = (TextView) findViewById(R.id.sudu);

        sudu2 = (TextView) findViewById(R.id.sudu2);
        // 视频缓冲进度条
        bar = findViewById(R.id.pb);
        // 视频缓冲的进度,百分比
        textViewBF = (TextView) bar.findViewById(R.id.buff);
        // 视频已经播放的时间
        play_tiem = (TextView) findViewById(R.id.play_time);
        // 视频播放总时间
        endTime = (TextView) findViewById(R.id.play_end_time);
        // 视频名称,并设置监听
        nametTextView = (TextView) findViewById(R.id.movie_name);
        nametTextView.setOnClickListener(this);
        // 视频的时间
        timeTextView = (TextView) findViewById(R.id.movie_time);
        // 得到当前时间(通过时间戳的装换函数Timestamp)
        timeString = (new Timestamp(System.currentTimeMillis())).toString()
                .substring(11, 16);
        timeTextView.setText(timeString);
        // 视频质量设定按钮,并设置监听按钮
        chiceButton = (Button) findViewById(R.id.zhiliang);
        chiceButton.setOnClickListener(this);
        // 快退按钮 ,并设置监听
        fontbButton = (Button) findViewById(R.id.font);
        fontbButton.setOnClickListener(this);
        // 播放按钮,并设置监听
        playbButton = (Button) findViewById(R.id.play);
        playbButton.setOnClickListener(this);
        // 快进按钮并设置监听
        nextButton = (Button) findViewById(R.id.next);
        nextButton.setOnClickListener(this);
        // 控制喇叭音量
        mVolumeBrightnessLayout = findViewById(R.id.operation_volume_brightness);
        // 喇叭图片
        mOperationBg = (ImageView) findViewById(R.id.operation_bg);
        // 音量控制的进度条
        mOperationPercent = (ImageView) findViewById(R.id.operation_percent);
        // 手势操作类,并设置手势监听
        mGestureDetector = new GestureDetector(this, new MyGestureListener());
        // 获取系统服务
        mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
        // 获取系统的最大音量
        mMaxVolume = mAudioManager
                .getStreamMaxVolume(AudioManager.STREAM_MUSIC);
        // 控制屏幕翻转
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        // 更新seekbar,即视频播放进度监听
        setListener();
        // 更新seekbar时,根据视频播放进度跟新时间等数据
        update = new upDateSeekBar();
        new Thread(update).start();
    }

    private class MyGestureListener extends SimpleOnGestureListener {
        @Override
        // 当用户在屏幕上"滚动"时触发该方法
        public boolean onScroll(MotionEvent e1, MotionEvent e2,
                float distanceX, float distanceY) {
            // 得到x,y坐标当前值,相对于当前view
            float mOldX = e1.getX(), mOldY = e1.getY();
            // getRawY()是表示相对于屏幕左上角的y坐标值
            int y = (int) e2.getRawY();
            // 获得屏幕的宽高
            Display disp = getWindowManager().getDefaultDisplay();
            int windowWidth = disp.getWidth();
            int windowHeight = disp.getHeight();
            // 右边滑动
            if (mOldX > windowWidth * 4.0 / 5)
                onVolumeSlide((mOldY - y) / windowHeight);
            // 左边滑动
            else if (mOldX < windowWidth / 5.0)
                onBrightnessSlide((mOldY - y) / windowHeight);
            return super.onScroll(e1, e2, distanceX, distanceY);
        }
    }

    /**
     * 滑动改变声音大小
     *
     * @param percent
     */
    private void onVolumeSlide(float percent) {
        if (mVolume == -1) {
            mVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
            if (mVolume < 0)
                mVolume = 0;

            // 显示声音的大小
            mOperationBg.setImageResource(R.drawable.video_volumn_bg);
            mVolumeBrightnessLayout.setVisibility(View.VISIBLE);
        }

        int index = (int) (percent * mMaxVolume) + mVolume;
        if (index > mMaxVolume)
            index = mMaxVolume;
        else if (index < 0)
            index = 0;
        // 变更声音
        mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, index, 0);
        // 变更进度条
        ViewGroup.LayoutParams lp = mOperationPercent.getLayoutParams();
        lp.width = findViewById(R.id.operation_full).getLayoutParams().width
                * index / mMaxVolume;
        mOperationPercent.setLayoutParams(lp);
    }

    /**
     * 滑动改变亮度
     *
     * @param percent
     */
    private void onBrightnessSlide(float percent) {
        if (mBrightness < 0) {
            mBrightness = getWindow().getAttributes().screenBrightness;
            if (mBrightness <= 0.00f)
                mBrightness = 0.50f;
            if (mBrightness < 0.01f)
                mBrightness = 0.01f;

            // 显示
            mOperationBg.setImageResource(R.drawable.video_brightness_bg);
            mVolumeBrightnessLayout.setVisibility(View.VISIBLE);
        }

        WindowManager.LayoutParams lpa = getWindow().getAttributes();
        lpa.screenBrightness = mBrightness + percent;
        if (lpa.screenBrightness > 1.0f)
            lpa.screenBrightness = 1.0f;
        else if (lpa.screenBrightness < 0.01f)
            lpa.screenBrightness = 0.01f;
        getWindow().setAttributes(lpa);
        // 变更进度条
        ViewGroup.LayoutParams lp = mOperationPercent.getLayoutParams();
        lp.width = (int) (findViewById(R.id.operation_full).getLayoutParams().width * lpa.screenBrightness);
        mOperationPercent.setLayoutParams(lp);
    }
    //播放视频
    private void play() {
        Log.i("hck", "play flag1:  " + urls.get(flag));
        isPlay = true;
        try {
            videoView.setVideoURI(Uri.parse(urls.get(flag)));
            videoView.setOnCompletionListener(this);
            videoView.setOnBufferingUpdateListener(this);
            videoView.setOnErrorListener(this);
            videoView.setOnInfoListener(this);
            videoView.setOnPreparedListener(this);

        } catch (Exception e) {
            Log.i("hck", "PlayActivity " + e.toString());
        }
    }

    class upDateSeekBar implements Runnable {

        @Override
        public void run() {
            if (!isFinish) {
                mHandler.sendMessage(Message.obtain());
                mHandler.postDelayed(update, 1000);
            }

        }
    }
    //通过用户指定的播放进度更新时间等信息
    @SuppressLint("HandlerLeak")
    Handler mHandler = new Handler() {
        public void handleMessage(Message msg) {
            if (videoView == null) {
                return;
            }
            timeString = (new Timestamp(System.currentTimeMillis())).toString()
                    .substring(11, 16);
            timeTextView.setText(timeString);
            play_tiem.setText(StringUtils.generateTime(videoView
                    .getCurrentPosition()));
            if (videoView != null) {
                seekBar(videoView.getCurrentPosition());
            }

        };
    };

    private void seekBar(long size) {
        if (videoView.isPlaying()) {
            long mMax = videoView.getDuration();
            int sMax = seekBar.getMax();
            seekBar.setProgress((int) (size * sMax / mMax));

        }
    }

    private void setListener() {
        seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {

                int value = (int) (seekBar.getProgress()
                        * videoView.getDuration() / seekBar.getMax());
                videoView.seekTo(value);
                videoView.start();
                isPlay = true;
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
                isPlay = false;
                videoView.pause();
            }

            @Override
            public void onProgressChanged(SeekBar seekBar, int progress,
                    boolean fromUser) {

            }
        });

    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (mGestureDetector.onTouchEvent(event))
            return true;
        switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            if (!isLock) {
                fLayout.setVisibility(View.VISIBLE);
                layout.setVisibility(View.VISIBLE);

            }
            imageView.setVisibility(View.VISIBLE);
            break;
        case MotionEvent.ACTION_UP:       // 处理手势结束            endGesture();
            break;

        default:
            break;
        }
        return super.onTouchEvent(event);
    }
  /** 手势结束 */
    private void endGesture() {
        mVolume = -1;
        mBrightness = -1f;
        // 隐藏
        disHandler.removeMessages(0);
        disHandler.sendEmptyMessageDelayed(0, 1000);
        disHandler.removeMessages(1);
        disHandler.sendEmptyMessageDelayed(1, 5000);
    }

    private Handler disHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            if (msg.what == 0) {
                mVolumeBrightnessLayout.setVisibility(View.GONE);
            } else {
                fLayout.setVisibility(View.GONE);
                layout.setVisibility(View.GONE);
                imageView.setVisibility(View.GONE);
                if (pWindow != null && pWindow.isShowing()) {
                    pWindow.dismiss();
                }
            }

        }
    };

    @SuppressLint("HandlerLeak")
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
        case R.id.play:
            if (isPlay) {
                videoView.pause();
                playbButton
                        .setBackgroundResource(R.drawable.player_play_highlight);
                isPlay = false;
                seekBar.setEnabled(false);
            } else {
                playbButton
                        .setBackgroundResource(R.drawable.player_pause_highlight);
                videoView.start();
                isPlay = true;
                seekBar.setEnabled(true);
            }
            break;
        case R.id.image_lock:
            if (isLock) {
                isLock = false;
                imageView.setBackgroundResource(R.drawable.lock_off);
            } else {
                isLock = true;
                imageView.setBackgroundResource(R.drawable.lock_on);
            }
            break;
        case R.id.next:
            videoView.pause();
            if (videoView != null) {
                size = videoView.getCurrentPosition() + videoView.getDuration()
                        / 10;
                videoView.seekTo(size);
                videoView.start();
            }
            break;
        case R.id.font:
            videoView.pause();
            if (videoView != null) {
                size = videoView.getCurrentPosition() - videoView.getDuration()
                        / 10;
                videoView.seekTo(size);
                videoView.start();
            }
            break;
        case R.id.zhiliang:
            Log.i("hck", "zhiliang");
            showPop(v);
            break;

        }
    }

    @Override
    public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) {

    }

    @Override
    public void surfaceCreated(SurfaceHolder arg0) {
        Log.i("hck", "surfaceCreated");
    }

    @Override
    public void surfaceDestroyed(SurfaceHolder arg0) {

    }

    @Override
    public void onVideoSizeChanged(MediaPlayer arg0, int arg1, int arg2) {
    }

    @Override
    public void onPrepared(MediaPlayer arg0) {
        nextButton.setEnabled(true);
        fontbButton.setEnabled(true);
        bar.setVisibility(View.GONE);
        if (urls.get(flag).startsWith("http")) {
            videoView.setBufferSize(1024 * 1000);
        } else {
            videoView.setBufferSize(0);
        }
        endTime.setText(StringUtils.generateTime(videoView.getDuration()));
        bar.setVisibility(View.GONE);
        if (pauseSize > 0) {
            videoView.seekTo(pauseSize);
        }
        pauseSize = 0;
    }

    @Override
    public void onCompletion(MediaPlayer arg0) {
        videoView.stopPlayback();
    }

    @Override
    public void onBufferingUpdate(MediaPlayer arg0, int arg1) {
        textViewBF.setTextColor(Color.CYAN);
        textViewBF.setText(videoView.getBufferPercentage() + "%");

    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        videoView.setVideoLayout(3, 0);
    }

    @Override
    public boolean onError(MediaPlayer arg0, int arg1, int arg2) {
        Log.i("hck", "error :" + arg1 + arg2);
        return false;
    }

    @Override
    public boolean onInfo(MediaPlayer arg0, int arg1, int arg2) {
        switch (arg1) {
        case MediaPlayer.MEDIA_INFO_BUFFERING_START:
            if (isPlay) {
                bar.setVisibility(View.VISIBLE);
                videoView.pause();
                isPlay = false;

            }
            break;
        case MediaPlayer.MEDIA_INFO_BUFFERING_END:
            if (!isPlay) {
                bar.setVisibility(View.GONE);
                videoView.start();
                isPlay = true;

            }
            break;
        case MediaPlayer.MEDIA_INFO_DOWNLOAD_RATE_CHANGED:
            sudu.setTextColor(Color.CYAN);
            sudu.setText(arg2 + "kb/s");
            sudu2.setText(arg2 + "kb/s");
            break;
        }
        return true;
    }

    @Override
    protected void onPause() {
        super.onPause();
        videoView.pause();

    }

    @Override
    protected void onResume() {
        super.onResume();
        if (isPlay) {
            videoView.start();
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (videoView != null) {
            videoView.stopPlayback();
            videoView = null;
        }
        if (pWindow != null && pWindow.isShowing()) {
            pWindow.dismiss();
        }
        isPlay = false;
        isFinish = true;
        System.gc();

    }

    @Override
    public void onSeekComplete(MediaPlayer arg0) {

    }

    private void showPop(View view2) {

        // View view = LayoutInflater.from(this).inflate(R.layout.pop, null);
        // qingxiButton = (Button) view.findViewById(R.id.qingxi);
        // gaoqingButton = (Button) view.findViewById(R.id.gaoqing);
        // liuchangButton = (Button) view.findViewById(R.id.liuchang);
        // pWindow = new PopupWindow(view, LayoutParams.WRAP_CONTENT,
        // LayoutParams.WRAP_CONTENT);
        // pWindow.setOutsideTouchable(true);
        // pWindow.showAtLocation(view2, Gravity.LEFT, Gravity.LEFT, 1);
        // setListener2();

    }

    private void setListener2() {
        qingxiButton.setOnClickListener(this);
        gaoqingButton.setOnClickListener(this);
        liuchangButton.setOnClickListener(this);
    }

}

缺少 :/** 当前缩放模式 */
        private int mLayout = VideoView.VIDEO_LAYOUT_ZOOM;、

参考:http://www.cnblogs.com/over140/archive/2012/05/22/2473019.html

xml代码

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#000000" >

    <io.vov.vitamio.widget.VideoView
        android:id="@+id/surface_view"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true" />

    <FrameLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

        <!-- 视频信息 -->

        <FrameLayout
            android:id="@+id/title_fl"
            android:layout_width="fill_parent"
            android:layout_height="50dp"
            android:background="@drawable/test_widget_bg"
            android:visibility="gone" >

            <TextView
                android:id="@+id/movie_name"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:textColor="#ffffff"
                android:textSize="16sp" />

            <TextView
                android:id="@+id/movie_time"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="right|center_vertical"
                android:layout_marginRight="10dp"
                android:text="11:34"
                android:textColor="#ffffff" />
        </FrameLayout>
        <!-- 屏幕是否解锁 -->

        <ImageView
            android:id="@+id/image_lock"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="left"
            android:layout_marginLeft="15dp"
            android:layout_marginTop="15dp"
            android:src="@drawable/lock_off"
            android:visibility="gone" />

        <LinearLayout
            android:id="@+id/buttom_lin"
            android:layout_width="fill_parent"
            android:layout_height="70dp"
            android:layout_gravity="bottom"
            android:background="@drawable/test_widget_bg"
            android:gravity="center_vertical"
            android:orientation="vertical" >

            <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" >

                <!-- 视频已经播放的时间 -->

                <TextView
                    android:id="@+id/play_time"
                    android:layout_alignParentLeft="true"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="3dp"
                    android:text="20:12:33"
                    android:textColor="#ffffff"
                    android:textSize="12sp" />
                <!-- 视频播放进度条 -->

                <SeekBar
                    android:id="@+id/seekBar"
                    style="@style/player_progressBarStyleHorizontal"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_vertical"
                    android:layout_toLeftOf="@+id/play_end_time"
                    android:layout_toRightOf="@+id/play_time" />

                <!-- 视频播放总时间 -->

                <TextView
                    android:id="@+id/play_end_time"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true"
                    android:layout_centerVertical="true"
                    android:layout_marginRight="3dp"
                    android:text="20:12:33"
                    android:textColor="#ffffff"
                    android:textSize="12sp" />
            </RelativeLayout>

            <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal" >

                <!-- 视频质量设定按钮 -->

                <Button
                    android:id="@+id/zhiliang"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="15dp"
                    android:background="@drawable/player_quality_current_background"
                    android:onClick="showP"
                    android:text="质量"
                    android:textColor="#ffffff"
                    android:textSize="12sp" />

                <FrameLayout
                    android:layout_width="200dp"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true" >

                    <!-- 快退按钮 -->

                    <Button
                        android:id="@+id/font"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="left"
                        android:background="@drawable/player_prev_highlight" />
                    <!-- 播放,停止按钮 -->

                    <Button
                        android:id="@+id/play"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:background="@drawable/player_pause_highlight" />
                    <!-- 快进按钮 -->

                    <Button
                        android:id="@+id/next"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="right"
                        android:background="@drawable/test_player_next_highlight" />
                </FrameLayout>

                <TextView
                    android:id="@+id/sudu2"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:layout_alignParentRight="true"
                    android:layout_marginRight="2dp"
                    android:gravity="center_vertical"
                       android:text="显示"
                    android:textColor="#ffffff"
                    android:textSize="14sp" />
            </RelativeLayout>
        </LinearLayout>
    </FrameLayout>
    <!-- 控制喇叭音量 -->

    <FrameLayout
        android:id="@+id/operation_volume_brightness"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:background="#00000000"
        android:orientation="horizontal"
        android:padding="0dip"
        android:visibility="invisible" >

        <ImageView
            android:id="@+id/operation_bg"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:src="@drawable/video_volumn_bg" />

        <FrameLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|center_horizontal"
            android:paddingBottom="25dip" >

            <ImageView
                android:id="@+id/operation_full"
                android:layout_width="94dip"
                android:layout_height="wrap_content"
                android:layout_gravity="left"
                android:src="@drawable/video_num_bg" />

            <ImageView
                android:id="@+id/operation_percent"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_gravity="left"
                android:scaleType="matrix"
                android:src="@drawable/video_num_front" />
        </FrameLayout>
    </FrameLayout>
    <!-- 视频缓冲进度条 -->

    <LinearLayout
        android:id="@+id/pb"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:orientation="horizontal" >
        <TextView
            android:id="@+id/sudu"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginRight="5dp"
            android:textColor="#ffffff"
            android:textSize="18sp" />

        <TextView
            android:id="@+id/buff"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:text="0%"
            android:textSize="18sp" />

        <ProgressBar
            style="@android:style/Widget.ProgressBar.Small"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center" />
    </LinearLayout>

</RelativeLayout>
时间: 2024-08-02 15:11:35

Vitamio视频播放的相关文章

Vitamio 视频播放

 资料总结 Vitamio官网:https://www.vitamio.org 源码地址:https://github.com/yixia/VitamioBundle 最佳教程:大名鼎鼎的农民伯伯博客http://www.cnblogs.com/over140/category/409230.html,农民伯伯应该是这个开发团队的一员. VPlayer好像是这个框架的最佳产品,不过看到官网的一些合作伙伴,如果确实是用到这个框架的话,好像也很不错(可以反编译看看,学习学习~) 下面是农名伯伯开发教

github视频录制播放相关功能-参考

lookingstars/JZVideoDemo  视频播放器 Updated on 11 Aug Objective-C 15 10 caoguoqing/VideoEditDemo  iOS video cut ,also can add blackgroundmusic iOS 视频剪辑,视频添加背景音乐 Updated on 13 Jun 2014 Objective-C 139 50 835239104/KrVideoPlayerPlus  根据36Kr开源的KRVideoPlayer

非常有用的GitHub链接

平常开发工作中,我经常取Github上搜索项目,Clone下来学习使用,在这个过程中,发现了好多比较好的Github地址,记录下来,分享出去. image 非常有用的GitHub链接(顺序不分先后): 1. https://github.com/jeasonlzy: OkHttpUtils-2.0.0 升级后改名 OkGo,全新完美支持RxJava,比Retrofit更简单易用. 完全仿微信的图片选择,并且提供了多种图片加载接口,选择图片后可以旋转,可以裁剪成矩形或圆形,可以配置各种其他的参数

视频播放-VideoVIew,Vitamio

播放视频文件其实并不比播放音频文件复杂,主要是使用 VideoView类来实现的.这个类将视频的显示和控制集于一身,使得我们仅仅借助它就可以完成一个简易的视频播放器.VideoView的用法和 MediaPlayer 也比较类似(不同点在于播放视频需要UI控件,播放音乐只需要借助MediaPlayer对象) VideoView,用于播放一段视频媒体,它继承了SurfaceView,位于"android.widget.VideoView",是一个视频控件. 常用监听: setOnComp

Android本地文件点击视频播放器vitamio版

本博客用Android studio集成了vitamio的自定义视频播放器,同时可以在文件管理中选择播放,想要一个自己的视频播放器这边便可以满足 实现具体功能如下: 1.sd卡内存视频文件的点击播放; 2.视频时间进度条; 3.屏幕亮度的手势滑动; 4.视频音量的手势滑动; 5.多点手势效果 6.自定义存储视频url播放 想要的重要的代码,我懂得: ------------------------------软件工程结构图: 最重要的是依赖上vitamio库: -----------------

玩转Android之在线视频播放控件Vitamio的使用

其实Android中自带的MediaPlayer本身就能播放在线视频,MediaPlayer结合SurfaceView播放在线视频也是不错的选择(如果你没有性能或者用户体验上的要求),关于MediaPlayer+SurfaceView播放在线视频我后面会给筒子们详细介绍,这里我想先说一下一个第三方的视频播放控件Vitamio的使用,这个控件用起来还是非常方便的,而且性能也不错,OK,废话不多说,先来看看我们今天的一个效果图. OK,这是一段网络视频,当视频处于缓冲状态时,会提示用户目前缓冲的百分

Android--使用开源vitamio做万能视频播放器

Vitamio 是什么? Vitamio 是一款 Android 与 iOS 平台上的全能多媒体开发框架,全面支持硬件解码与 GPU 渲染.Vitamio 凭借其简洁易用的 API 接口赢得了全球众多开发者的青睐.到目前,全球已经有超过 一万 种应用在使用 Vitamio,覆盖用户超过 5亿 . Vitamio 能够流畅播放720P甚至1080P高清MKV,FLV,MP4,MOV,TS,RMVB等常见格式的视频,还可以在 Android 与 iOS 上跨平台支持 MMS, RTSP, RTMP,

集成Vitamio的视频播放器

项目现在已经差不多稳定了,总结自己这段时间的经历. 公司的项目是一款配合路由器的app,但是说到底其实都一样,只是在取数据的时候把网络,换成了一个路由器.公式的项目哗哗Wifi ,主要做的是视频以及免费上网.     视频功能: 1.视频播放的控制台,进度条,播放.暂停按钮.播放时长,返回按钮,播放影片的名称 2.调节音量 3.调节亮度 4.拖动屏幕来进行视频的快进跟快退 5.视频在横竖屏切换的时候的显示(注:动态改变vidwoView的高度能解决切换的时候自适应的问题) 开发的资料: 1.首先

Vitamio(中文:维他蜜)使用第三方框架实现视频播放

第一步:下载Vitamio Vitamio 完整下载包是 Vitamio-iOS-version.zip(https://github.com/yixia/Vitamio-iOS/archive/master.zip), 解压缩后包含 Demo, Vitamio, Doc 三个部分, 第二步: 将下载的Vitamio工程改成下列形式,也就是拖线,分组, 第三步: 在Xcode中,新建一个工程,将Vitamio拖入到工程中,此时运行是正常的 第四步: 配置tarGet,改参数,按顺序导入框架. 第