视频播放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" }
相关文章推荐
- CEWL
- Android第四十三天
- 【笔记】JS基础一
- rsync同步的艺术
- C#新手入门代码 控制台清屏
- Wifi小车之 - 第一版小车问世
- core dump
- clob与blob转为char
- 剑指offer面试题43:n个骰子的点数
- 使用Thinkphp小结1,增删改查
- php基础之 ->, =>,@,&,::,%符号
- POJ-2533-Longest Ordered Subsequence
- poj1466
- 内存映射
- POJ-1936-All in All
- css优先级
- 用js去除重复元素的两种方法总结
- Codevs 4560 NOIP2015 D2T2 子串
- 组播的三个儿子
- Java中String、StringBuffer和StringBuilder