IJKplayer播放视频
首先导入依赖包:
compile 'com.dou361.ijkplayer:jjdxm-ijkplayer:1.0.5'
compile 'tv.danmaku.ijk.media:ijkplayer-armv5:0.6.0'
compile 'tv.danmaku.ijk.media:ijkplayer-arm64:0.6.0' //最小版本 21
compile 'tv.danmaku.ijk.media:ijkplayer-x86:0.6.0'
compile 'tv.danmaku.ijk.media:ijkplayer-x86_64:0.6.0' //最小版本 21
如果全屏播放就不用粘贴布局了;如果是屏幕中一小块的话就粘贴这个布局:
<include layout="@layout/simple_player_view_player" android:layout_width="match_parent" android:layout_height="180dp"/>
然后是代码粘贴到MainActivity的onCreat中就可以:
/*View rootView = getLayoutInflater().from(this).inflate(R.layout.simple_player_view_player, null); setContentView(rootView);*/ String url = Environment.getExternalStorageDirectory() .getAbsolutePath() + "/local2/adc.mp4"; new PlayerView(this) .setTitle("什么") .setScaleType(PlayStateParams.fitparent) .hideMenu(true) .forbidTouch(false) .setPlaySource(url) .startPlay();
注释部分如果你要全屏播放就打开要不是的话就注释掉,我播放的是本地视频(就是我上一篇博客下载好的),这个也可以播放网络视频,只要把url改好把权限加上(网络,读写,网络状态)就行;
如果需要具体详细的功能可以看这个博客: