////////////////////////////////////////////////////方法一视频在文件中
1.首先导入依赖包:
compile 'com.dou361.ijkplayer:jjdxm-ijkplayer:1.0.5'2.如果全屏播放就不用粘贴布局了;如果是屏幕中一小块的话就粘贴这个布局:
<include layout="@layout/simple_player_view_player" android:layout_width="match_parent" android:layout_height="180dp"/>3.然后是代码粘贴到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改好把权限加上(网络,读写,网络状态)就行;<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>/////////////////////////////////////////////////////////////////////////////////方法二 添加需要的视频路径compile 'com.dou361.ijkplayer:jjdxm-ijkplayer:1.0.0'<include layout="@layout/simple_player_view_player" android:layout_width="match_parent" android:layout_height="180dp"/>//在Oncreate方法中写/*View rootView = getLayoutInflater().from(this).inflate(R.layout.simple_player_view_player, null); setContentView(rootView);*/ String url ="http://ips.ifeng.com/video19.ifeng.com/video09/2014/06/16/1989823-102-086-0009.mp4"; new PlayerView(this) .setTitle("什么") .setScaleType(PlayStateParams.fitparent) .hideMenu(true) .forbidTouch(false) .setPlaySource(url) .startPlay();}//获取数据compile 'com.github.leifzhang:IjkLib:0.4.3'<tv.danmaku.ijk.media.widget.media.IjkVideoView android:id="@+id/ijkplay" android:layout_width="match_parent" android:layout_height="200dp"> </tv.danmaku.ijk.media.widget.media.IjkVideoView>viewById = (IjkVideoView) findViewById(R.id.ijkplay);if (tag.equals("详情")) { XiangqingBean bean = (XiangqingBean) o; text1.setText(bean.getRet().getTitle()); String hdurl = bean.getRet().getHDURL(); if(hdurl!=null){ String url = hdurl; AndroidMediaController androidMediaController = new AndroidMediaController(this, false); viewById.setMediaController(androidMediaController); viewById.setVideoURI(Uri.parse(url)); viewById.start(); }