視頻播放vitamio

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import io.vov.vitamio.MediaPlayer;
import io.vov.vitamio.Vitamio;
import io.vov.vitamio.widget.MediaController;
import io.vov.vitamio.widget.VideoView;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Vitamio.isInitialized(getApplicationContext());
        setContentView(R.layout.activity_main);
        playfunction();
    }

    void playfunction() {
        String path = "http://123.56.111.226:8080/time.mp4";
        VideoView mVideoView;
        mVideoView = (VideoView) findViewById(R.id.vv);
        mVideoView.setVideoPath(path);
        mVideoView.setMediaController(new MediaController(this));
        mVideoView.requestFocus();
        mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
            @Override
            public void onPrepared(MediaPlayer mediaPlayer) {
                mediaPlayer.setPlaybackSpeed(1.0f);
            }
        });
    }
}
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.linson.myapplication.MainActivity">

    <io.vov.vitamio.widget.VideoView
        android:id="@+id/vv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
    </io.vov.vitamio.widget.VideoView>

</android.support.constraint.ConstraintLayout>

1,先下載vitamo  https://www.vitamio.org/Download/android

2,import module vitamioapp

3,修改build.gradleide

  compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)gradle

  buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSIONui

  defaultConfig {
  minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
  targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)this

  改成spa

 compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
minSdkVersion 22
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
相關文章
相關標籤/搜索