首先需要导入一个依赖
compile 'com.dou361.ijkplayer:jjdxm-ijkplayer:1.0.5'
把下面这段代码直接粘到onCreate里
View rootView = getLayoutInflater().from(this).inflate(R.layout.simple_player_view_player, null);
setContentView(rootView);
new PlayerView(this)
.setTitle("什么")
.setScaleType(PlayStateParams.fitparent)
.hideMenu(true)
.forbidTouch(false)
.setPlaySource("http://ips.ifeng.com/video19.ifeng.com/video09/2014/06/16/1989823-102-086-0009.mp4") //里面写你播放视频的地址
.startPlay();
布局的代码
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="wangyetian.bwie.com.ijkplayer.MainActivity">
<com.dou361.ijkplayer.widget.IjkVideoView
android:id="@+id/ijk_iv_rotation"
android:layout_width="match_parent"
android:layout_height="match_parent"></com.dou361.ijkplayer.widget.IjkVideoView>
</RelativeLayout>
记得不要忘记加上权限,否则不会出来的
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"/>