|
|
|
|
@@ -13,15 +13,17 @@ import com.mogo.module.common.entity.MarkerExploreWayItem;
|
|
|
|
|
import com.mogo.module.common.entity.V2XEventShowEntity;
|
|
|
|
|
import com.mogo.module.common.entity.V2XRoadEventEntity;
|
|
|
|
|
import com.mogo.module.v2x.R;
|
|
|
|
|
import com.mogo.module.v2x.SimpleCoverVideoPlayer;
|
|
|
|
|
import com.mogo.module.v2x.V2XServiceManager;
|
|
|
|
|
import com.mogo.module.v2x.listener.V2XWindowStatusListener;
|
|
|
|
|
import com.mogo.module.v2x.scenario.view.IV2XWindow;
|
|
|
|
|
import com.mogo.module.v2x.view.TextureVideoView;
|
|
|
|
|
import com.mogo.utils.BitmapHelper;
|
|
|
|
|
import com.mogo.utils.logger.Logger;
|
|
|
|
|
import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
|
|
import com.mogo.module.v2x.VideoInitKt;
|
|
|
|
|
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -29,10 +31,11 @@ public class V2XRoadVideoWindow extends RelativeLayout implements IV2XWindow, ID
|
|
|
|
|
|
|
|
|
|
private static final String TAG = "V2XRoadVideoWindow";
|
|
|
|
|
private V2XWindowStatusListener mV2XWindowStatusListener;
|
|
|
|
|
private TextureVideoView mVideoView;
|
|
|
|
|
private SimpleCoverVideoPlayer simpleCoverVideoPlayer;
|
|
|
|
|
private ImageView closeImage;
|
|
|
|
|
private ImageView mThumbnailImageView;
|
|
|
|
|
private ImageView windowPalyImageView;
|
|
|
|
|
private GSYVideoOptionBuilder gsyVideoOptionBuilder = new GSYVideoOptionBuilder();
|
|
|
|
|
|
|
|
|
|
public V2XRoadVideoWindow() {
|
|
|
|
|
this(V2XServiceManager.getContext(), null);
|
|
|
|
|
@@ -53,20 +56,20 @@ public class V2XRoadVideoWindow extends RelativeLayout implements IV2XWindow, ID
|
|
|
|
|
|
|
|
|
|
private void initView(Context context) {
|
|
|
|
|
LayoutInflater.from(context).inflate(R.layout.window_road_video, this);
|
|
|
|
|
mVideoView = findViewById(R.id.roadVideoView);/*播放器*/
|
|
|
|
|
simpleCoverVideoPlayer = findViewById(R.id.roadVideoView);/*播放器*/
|
|
|
|
|
windowPalyImageView = findViewById(R.id.window_video_play);/*播放键*/
|
|
|
|
|
mThumbnailImageView = findViewById(R.id.thumbnail_image);/*第一帧图片*/
|
|
|
|
|
closeImage = findViewById(R.id.roadVideoClose);
|
|
|
|
|
closeImage.setOnClickListener(v -> {
|
|
|
|
|
close();
|
|
|
|
|
});
|
|
|
|
|
mVideoView.setOnClickListener(v -> {
|
|
|
|
|
simpleCoverVideoPlayer.setOnClickListener(v -> {
|
|
|
|
|
mThumbnailImageView.setVisibility(View.GONE);
|
|
|
|
|
if (mVideoView.isPlaying()) {
|
|
|
|
|
videoPause();
|
|
|
|
|
} else {
|
|
|
|
|
videoResume();
|
|
|
|
|
}
|
|
|
|
|
// if (simpleCoverVideoPlayer.isPlaying()) {
|
|
|
|
|
// videoPause();
|
|
|
|
|
// } else {
|
|
|
|
|
// videoResume();
|
|
|
|
|
// }
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -84,10 +87,10 @@ public class V2XRoadVideoWindow extends RelativeLayout implements IV2XWindow, ID
|
|
|
|
|
if (path.contains(".mp4")) {
|
|
|
|
|
videoViewStartWithPath(path);
|
|
|
|
|
|
|
|
|
|
mVideoView.setOnCompletionListener(mediaPlayer -> {
|
|
|
|
|
Logger.w(MODULE_NAME, "视频播放结束...");
|
|
|
|
|
videoPlayEnd(path);
|
|
|
|
|
});
|
|
|
|
|
// mVideoView.setOnCompletionListener(mediaPlayer -> {
|
|
|
|
|
// Logger.w(MODULE_NAME, "视频播放结束...");
|
|
|
|
|
// videoPlayEnd(path);
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -98,20 +101,25 @@ public class V2XRoadVideoWindow extends RelativeLayout implements IV2XWindow, ID
|
|
|
|
|
* 视频开始播放
|
|
|
|
|
* */
|
|
|
|
|
private void videoViewStartWithPath(String path) {
|
|
|
|
|
mVideoView.setVisibility(VISIBLE);
|
|
|
|
|
mVideoView.setVideoPath(path);
|
|
|
|
|
mVideoView.setOnPreparedListener(mediaPlayer -> {
|
|
|
|
|
mThumbnailImageView.setVisibility(View.GONE);
|
|
|
|
|
windowPalyImageView.setVisibility(View.GONE);
|
|
|
|
|
});
|
|
|
|
|
mVideoView.start();
|
|
|
|
|
simpleCoverVideoPlayer.setVisibility(View.VISIBLE);
|
|
|
|
|
//加载封面图
|
|
|
|
|
// simpleCoverVideoPlayer.loadCoverImage(path, getContext());
|
|
|
|
|
gsyVideoOptionBuilder.setUrl(path).setCacheWithPlay(false).setPlayTag(TAG)
|
|
|
|
|
.build(simpleCoverVideoPlayer);
|
|
|
|
|
simpleCoverVideoPlayer.getStartButton().performClick();
|
|
|
|
|
|
|
|
|
|
// simpleCoverVideoPlayer.setOnPreparedListener(mediaPlayer -> {
|
|
|
|
|
// mThumbnailImageView.setVisibility(View.GONE);
|
|
|
|
|
// windowPalyImageView.setVisibility(View.GONE);
|
|
|
|
|
// });
|
|
|
|
|
// simpleCoverVideoPlayer.start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 视频暂停播放
|
|
|
|
|
* */
|
|
|
|
|
private void videoPause() {
|
|
|
|
|
mVideoView.pause();
|
|
|
|
|
// simpleCoverVideoPlayer.pause();
|
|
|
|
|
windowPalyImageView.setVisibility(View.VISIBLE);
|
|
|
|
|
windowPalyImageView.setOnClickListener(v -> {
|
|
|
|
|
videoResume();
|
|
|
|
|
@@ -122,8 +130,8 @@ public class V2XRoadVideoWindow extends RelativeLayout implements IV2XWindow, ID
|
|
|
|
|
* 视频暂停后继续播放
|
|
|
|
|
* */
|
|
|
|
|
private void videoResume() {
|
|
|
|
|
mThumbnailImageView.setVisibility(View.INVISIBLE);
|
|
|
|
|
mVideoView.resume();
|
|
|
|
|
// mThumbnailImageView.setVisibility(View.INVISIBLE);
|
|
|
|
|
// mVideoView.resume();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|