NiceVieoPlayer的二次封装
NiceVieoPlayer
初次写这个东西,也就是试试手,希望能帮到你
NiceVieoPlayer的简单使用
在 AndroidStudio 中作为 Mudule 添加如下依赖
api ‘com.github.xiaoyanger0825:NiceVieoPlayer:v2.2’
添加view
VideoPlayer
class VideoPlayer extends NiceVideoPlayer {
private Context mContext;
private String mUrl;
private VideoController mController;
public VideoPlayer(Context context) {
this(context, (AttributeSet) null);
}
public VideoPlayer(Context context, AttributeSet attrs) {
super(context, attrs);
this.mContext = context;
}
public void setUp(String url, Map<String, String> headers) {
super.setUp(url, headers);
this.mUrl = url;
}
public void setController(VideoController controller) {
mController = controller;
super.setController(controller);
}
public void release() {
// if (!this.isPlaying() && !this.isBufferingPlaying() && !this.isBufferingPaused() && !this.isPaused()) {
// if (this.isCompleted()) {
// NiceUtil.savePlayPosition(this.mContext, this.mUrl, 0L);
// }
// } else {
// }
// Log.e(“视频播放”, “退出播放”);
NiceUtil.savePlayPosition(this.mContext, this.mUrl, 0L);
if (this.isFullScreen()) {
this.exitFullScreen();
}
if (this.isTinyWindow()) {
this.exitTinyWindow();
}
this.releasePlayer();
if (this.mController != null) {
this.mController.reset();
}
Runtime.getRuntime().gc();
}
}
使用
private void init() {
mNiceVideoPlayer.setPlayerType(NiceVideoPlayer.TYPE_IJK);
mNiceVideoPlayer.setUp(videosUrl, null);
VideoController controller = new VideoController(this);
controller.setTitle("");
// GlideManager.loadImage(this, imageUrl, controller.imageView());
mNiceVideoPlayer.setController(controller);
controller.mCenterStart.performClick();
}
也不会写,主要的都在这了,在不懂的可以联系我
QQ370724926