/**
- 视频文件地址
*/
private String mPath = “”;
private SurfaceView surfaceView;
private VideoPlayerListener listener;
private Context mContext;
public VideoPlayerIJK(@NonNull Context context) {
super(context);
initVideoView(context);
}
public VideoPlayerIJK(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
initVideoView(context);
}
public VideoPlayerIJK(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
super(context, attrs, defStyleAttr);
initVideoView(context);
}
private void initVideoView(Context context) {
mContext = context;
//获取焦点,不知道有没有必要。
setFocusable(true);
}
/**
- 设置视频地址。
- 根据是否第一次播放视频,做不同的操作。
- @param path the path of the video.
*/
public void setVideoPath(St 《Android学习笔记总结+最新移动架构视频+大厂安卓面试真题+项目实战源码讲义》无偿开源 徽信搜索公众号【编程进阶路】 ring path) {
if (TextUtils.equals(“”, mPath)) {
//如果是第一次播放视频,那就创建一个新的surfaceView
mPath = path;
createSurfaceView();
} else {
//否则就直接load
mPath = path;
load();
}
}
/**