您的位置:首页 > 其它

视频播放vitamio

2016-07-28 08:12 246 查看
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/
2,import module vitamio

3,修改build.gradle

  compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)

  buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION

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

  改为

 compileSdkVersion 23
  buildToolsVersion "23.0.3"
  defaultConfig {
      minSdkVersion 22
      targetSdkVersion 23
      versionCode 1
      versionName "1.0"
      testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  }

  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: