ijkPlayer简便使用

节操的ijkPlater:

依赖:这个只支持mp4格式播放

compile 'fm.jiecao:jiecaovideoplayer:5.5'   //倒依赖的时候可能会出错,改下下面面的版本号
defaultConfig {
    minSdkVersion 16   //这个版本号可能需要改到16,我的原来是15
在清单文件中,在哪展示视频,就在哪个ctivity中加入两行代码    android:name=".MainActivity"
        android:configChanges="orientation|screenSize|keyboardHidden"
    	android:screenOrientation="portrait"
    	>
    android:id="@+id/jiecao_Player"
    android:layout_width="match_parent"
    android:layout_height="200dp">
jiecaoPlayer.setUp(path,jiecaoPlayer.SCREEN_LAYOUT_NORMAL,"视频");   //找出控件ID加入这行代码,OK,参数一视屏路径
参数三是标题(String类型)

另一个播放视频的:这个支持的格式多,可能多点,但是功能少
依赖:
compile 'com.github.leifzhang:IjkLib:0.4.3'
控件:
    android:id="@+id/ijkPlayer"
    android:layout_width="match_parent"
    android:layout_height="300dp" />
找出控件ID:
IjkMediaPlayer.loadLibrariesOnce(null);
IjkMediaPlayer.native_profileBegin("libijkplayer.so ");

AndroidMediaController controller = new AndroidMediaController(this, false);
ijkPlayer.setMediaController(controller);
// adapter = new IdAdapter(SecondActivity.this,list);
String url = "https://wdl.wallstreetcn.com/41aae4d2-390a-48ff-9230-ee865552e72d ";
// String url = "http://o6wf52jln.bkt.clouddn.com/演员.mp3";
ijkPlayer.setVideoURI(Uri.parse(url));
ijkPlayer.start();

又一个播放视频:

控件:

    android:id="@+id/movie_jump_detail_videoplayer"
    android:layout_width="match_parent"
    android:layout_height="300dp"/>
依赖:
compile 'fm.jiecao:jiecaovideoplayer:4.8.3'
代码:
String hdurl = ret.getHDURL();
boolean setUp = movieJumpDetailVideoplayer.setUp(hdurl/*视频路径*/, JCVideoPlayer.SCREEN_LAYOUT_LIST, ret.getTitle()/*标题*/);
if (setUp) {
    movieJumpDetailVideoplayer.thumbImageView.setScaleType(ImageView.ScaleType.FIT_XY);
    Glide.with(this).load(ret.getPic()/*图片*/).into(movieJumpDetailVideoplayer.thumbImageView);
}
Activity中优化:
@Override
public void onBackPressed() {
    if (JCVideoPlayer.backPress()) {
        return;
    }
    super.onBackPressed();
}

@Override
protected void onPause() {
    super.onPause();
    JCVideoPlayer.releaseAllVideos();
}
有条件的话,加入这个:<activity    android:name=".MainActivity"    
android:configChanges="orientation|screenSize|keyboardHidden"    
android:screenOrientation="portrait" /> 

你可能感兴趣的:(ijkPlayer简便使用)