github上地址https://github.com/lipangit/JieCaoVideoPlayer。
一:使用
1、添加類庫
compile 'fm.jiecao:jiecaovideoplayer:5.5.4'
2、創建布局
<fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard
android:id="@+id/videocontroller1"
android:layout_width="match_parent"
android:layout_height="200dp" />
3.設置視頻/MP3地址、縮略圖地址、標題
mJcVideoPlayerStandard = (JCVideoPlayerStandard) findViewById(R.id.jc_video);
mJcVideoPlayerStandard.setUp("http://video.jiecao.fm/11/23/xin/%E5%81%87%E4%BA%BA.mp4"
, JCVideoPlayerStandard.SCREEN_LAYOUT_NORMAL, "嫂子不信");
Picasso.with(this)
.load("http://img4.jiecaojingxuan.com/2016/11/23/00b026e7-b830-4994-bc87-38f4033806a6.jpg@!640_360")
.into(mJcVideoPlayerStandard.thumbImageView);
mJcVideoPlayerStandard .setJcUserAction(new MyUserActionStandard());4、在包含播放器的Fragment或Activity的onPause()方法中調用mJcVideoPlayerStandard .releaseAllVideos();
注:全屏導致崩潰的請在清單文件中當前activity中加上:
<activity
android:name=“.activity.MainActivity”
android:configChanges=“orientation”
android:screenOrientation=“portrait”></activity>
注:播放本地文件
String videoPath = Environment.getExternalStorageDirectory().getAbsoutlePath()+"/test.mp4";
File file = new File(videoPath);
if( !file.exists() ){
return;
}
mJcVideoPlayerStandard .setUp(file.getAbsolutePath(),JCVideoPlayerStandard.SCREEN_LAYOUT_NORMAL,"測試");