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,"测试");
网友评论