Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
董宏宇
2020-10-23 20:22:58 +08:00
25 changed files with 619 additions and 254 deletions

View File

@@ -69,7 +69,6 @@ public class V2XShareEventsFragment extends MvpFragment<V2XShareEventsFragment,
new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
recyclerView.setLayoutManager(linearLayoutManager);
loadingView = mRootView.findViewById(R.id.network_loading_imageview);
}
private void initData() {

View File

@@ -0,0 +1,10 @@
package com.mogo.module.v2x.listener;
public interface VideoAdapterCallBack {
/*
* 道路视频播放
* */
void videoPlayWithVideoUrl(String videoUrl);
void closeVideoWindow();
}

View File

@@ -3,6 +3,7 @@ package com.mogo.module.v2x.scenario.scene.road;
import android.content.Context;
import android.graphics.Bitmap;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
@@ -15,24 +16,37 @@ import com.mogo.module.common.entity.V2XRoadEventEntity;
import com.mogo.module.v2x.R;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.listener.V2XWindowStatusListener;
import com.mogo.module.v2x.listener.VideoAdapterCallBack;
import com.mogo.module.v2x.scenario.view.IV2XWindow;
import com.mogo.module.v2x.view.TextureVideoView;
import com.mogo.module.v2x.view.SimpleCoverVideoPlayer;
import com.mogo.utils.BitmapHelper;
import com.mogo.utils.logger.Logger;
import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder;
import com.shuyu.gsyvideoplayer.listener.VideoAllCallBack;
import com.shuyu.gsyvideoplayer.utils.GSYVideoType;
import com.shuyu.gsyvideoplayer.video.base.GSYVideoView;
import java.util.ArrayList;
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
import static com.mogo.module.v2x.VideoInitKt.initVideo;
import static com.shuyu.gsyvideoplayer.utils.GSYVideoType.SCREEN_MATCH_FULL;
public class V2XRoadVideoWindow extends RelativeLayout implements IV2XWindow, IDestroyable {
/*
https://github.com/CarGuo/GSYVideoPlayer/tree/master/doc SimpleCoverVideoPlayer文档
* */
public class V2XRoadVideoWindow extends RelativeLayout implements IV2XWindow, IDestroyable, VideoAdapterCallBack {
private static final String TAG = "V2XRoadVideoWindow";
private V2XWindowStatusListener mV2XWindowStatusListener;
private TextureVideoView mVideoView;
private ImageView playImageView;
private ImageView thumbnailImage;
private ImageView closeImage;
private ImageView mThumbnailImageView;
private ImageView windowPalyImageView;
private SimpleCoverVideoPlayer simpleCoverVideoPlayer;
private Context mContext;
private GSYVideoOptionBuilder gsyVideoOptionBuilder = new GSYVideoOptionBuilder();
public V2XRoadVideoWindow() {
this(V2XServiceManager.getContext(), null);
@@ -40,36 +54,96 @@ public class V2XRoadVideoWindow extends RelativeLayout implements IV2XWindow, ID
public V2XRoadVideoWindow(Context context) {
this(context, null);
mContext = context;
}
public V2XRoadVideoWindow(Context context, AttributeSet attrs) {
this(context, attrs, 0);
mContext = context;
}
public V2XRoadVideoWindow(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initView(context);
mContext = context;
initView(mContext);
}
private void initView(Context context) {
LayoutInflater.from(context).inflate(R.layout.window_road_video, this);
mVideoView = findViewById(R.id.roadVideoView);/*播放器*/
windowPalyImageView = findViewById(R.id.window_video_play);/*播放键*/
mThumbnailImageView = findViewById(R.id.thumbnail_image);/*第一帧图片*/
closeImage = findViewById(R.id.roadVideoClose);
LayoutInflater.from(mContext).inflate(R.layout.window_road_video_layout, this);
initVideo();
playImageView = this.findViewById(R.id.window_video_play);
thumbnailImage = this.findViewById(R.id.thumbnail_image);
simpleCoverVideoPlayer = this.findViewById(R.id.roadVideoView);
GSYVideoType.setShowType(SCREEN_MATCH_FULL);
closeImage = this.findViewById(R.id.roadVideoClose);
closeImage.setOnClickListener(v -> {
close();
});
mVideoView.setOnClickListener(v -> {
mThumbnailImageView.setVisibility(View.GONE);
if (mVideoView.isPlaying()) {
videoPause();
} else {
videoResume();
simpleCoverVideoPlayer.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Log.d(TAG, "onClick啦啦啦啦啦啦啦啦");
if (simpleCoverVideoPlayer.getCurrentState() == GSYVideoView.CURRENT_STATE_PAUSE) {/*播放中*/
resume();
} else {
pause();
}
}
});
}
/*
* 开始播放
* */
private void startPlayWithVideoUrl(String videoUrl) {
gsyVideoOptionBuilder.setUrl(videoUrl).setCacheWithPlay(false).setPlayTag(TAG)
.build(simpleCoverVideoPlayer);
simpleCoverVideoPlayer.getStartButton().performClick();
thumbnailImage.setVisibility(View.GONE);
playImageView.setVisibility(View.GONE);
playImageView.setImageResource(R.drawable.v2x_video_pause);
playImageView.setVisibility(View.GONE);
}
/*
* 暂停
* */
private void pause() {
playImageView.setVisibility(View.VISIBLE);
thumbnailImage.setVisibility(View.GONE);
playImageView.setOnClickListener(v -> {
simpleCoverVideoPlayer.onVideoResume();
});
thumbnailImage.setOnClickListener(v -> {
simpleCoverVideoPlayer.onVideoResume();
});
}
/*
* 继续
* */
private void resume() {
playImageView.setVisibility(View.GONE);
thumbnailImage.setVisibility(View.GONE);
}
/*
* 播放结束后
* */
private void complete(Bitmap firstbitmap, String path) {
thumbnailImage.setVisibility(View.VISIBLE);
thumbnailImage.setImageBitmap(firstbitmap);
playImageView.setImageResource(R.drawable.v2x_icon_event_play);
playImageView.setVisibility(View.VISIBLE);
playImageView.setOnClickListener(v -> {
startPlayWithVideoUrl(path);
});
thumbnailImage.setOnClickListener(v -> {
startPlayWithVideoUrl(path);
});
}
@Override
public void show(Object entity) {
V2XEventShowEntity showEntity = (V2XEventShowEntity) entity;
@@ -82,68 +156,110 @@ public class V2XRoadVideoWindow extends RelativeLayout implements IV2XWindow, ID
return;
}
if (path.contains(".mp4")) {
videoViewStartWithPath(path);
startPlayWithVideoUrl(path);
Bitmap firstbitmap = BitmapHelper.getVideoThumbnail(path);/*获取第一帧图*/
mVideoView.setOnCompletionListener(mediaPlayer -> {
Logger.w(MODULE_NAME, "视频播放结束...");
videoPlayEnd(path);
simpleCoverVideoPlayer.setVideoAllCallBack(new VideoAllCallBack() {
@Override
public void onAutoComplete(String url, Object... objects) {
complete(firstbitmap, path);
}
@Override
public void onClickResume(String url, Object... objects) {
thumbnailImage.setVisibility(View.GONE);
playImageView.setVisibility(View.GONE);
}
@Override
public void onClickStop(String url, Object... objects) {
Log.d(TAG,"onClickStop");
}
@Override
public void onStartPrepared(String url, Object... objects) {
Log.d(TAG,"onStartPrepared");
}
@Override
public void onPrepared(String url, Object... objects) {
}
@Override
public void onClickStartIcon(String url, Object... objects) {
}
@Override
public void onClickStartError(String url, Object... objects) {
}
@Override
public void onClickStopFullscreen(String url, Object... objects) {
}
@Override
public void onClickResumeFullscreen(String url, Object... objects) {
}
@Override
public void onClickSeekbar(String url, Object... objects) {
}
@Override
public void onClickSeekbarFullscreen(String url, Object... objects) {
}
@Override
public void onEnterFullscreen(String url, Object... objects) {
}
@Override
public void onQuitFullscreen(String url, Object... objects) {
}
@Override
public void onQuitSmallWidget(String url, Object... objects) {
}
@Override
public void onEnterSmallWidget(String url, Object... objects) {
}
@Override
public void onTouchScreenSeekVolume(String url, Object... objects) {
}
@Override
public void onTouchScreenSeekPosition(String url, Object... objects) {
}
@Override
public void onTouchScreenSeekLight(String url, Object... objects) {
}
@Override
public void onPlayError(String url, Object... objects) {
}
@Override
public void onClickStartThumb(String url, Object... objects) {
}
@Override
public void onClickBlank(String url, Object... objects) {
}
@Override
public void onClickBlankFullscreen(String url, Object... objects) {
Log.d(TAG, "onClickBlankFullscreen");
}
});
}
}
}
/*
* 视频开始播放
* */
private void videoViewStartWithPath(String path) {
mVideoView.setVisibility(VISIBLE);
mVideoView.setVideoPath(path);
mVideoView.setOnPreparedListener(mediaPlayer -> {
mThumbnailImageView.setVisibility(View.GONE);
windowPalyImageView.setVisibility(View.GONE);
});
mVideoView.start();
}
/*
* 视频暂停播放
* */
private void videoPause() {
mVideoView.pause();
windowPalyImageView.setVisibility(View.VISIBLE);
windowPalyImageView.setOnClickListener(v -> {
videoResume();
});
}
/*
* 视频暂停后继续播放
* */
private void videoResume() {
mThumbnailImageView.setVisibility(View.INVISIBLE);
mVideoView.resume();
}
/*
* 视频播放结束
* */
private void videoPlayEnd(String path) {
Bitmap bitmap = BitmapHelper.getVideoThumbnail(path);
mThumbnailImageView.setVisibility(View.VISIBLE);
mThumbnailImageView.setImageBitmap(bitmap);
windowPalyImageView.setVisibility(View.VISIBLE);
windowPalyImageView.setOnClickListener(v -> {
videoViewStartWithPath(path);
});
if (mV2XWindowStatusListener != null) {
mV2XWindowStatusListener.onViewClose();
}
}
@Override
public void close() {
//移除窗体
@@ -166,4 +282,14 @@ public class V2XRoadVideoWindow extends RelativeLayout implements IV2XWindow, ID
public void destroy() {
}
@Override
public void videoPlayWithVideoUrl(String videoUrl) {
}
@Override
public void closeVideoWindow() {
}
}

View File

@@ -1,8 +1,7 @@
package com.mogo.module.tanlu.video
package com.mogo.module.v2x.view
import android.content.Context
import android.util.AttributeSet
import android.util.Log
import android.view.Surface
import android.view.View
import android.widget.ImageView
@@ -34,11 +33,11 @@ class SimpleCoverVideoPlayer : StandardGSYVideoPlayer {
override fun init(context: Context) {
super.init(context)
coverImage = findViewById(R.id.thumbnail_image)
coverImage = findViewById(R.id.thumbImage)
start = findViewById(R.id.start)
fullscreen = findViewById(R.id.fullscreen)
if (mThumbImageViewLayout != null
&& (mCurrentState == -1 || mCurrentState == GSYVideoView.CURRENT_STATE_NORMAL || mCurrentState == GSYVideoView.CURRENT_STATE_ERROR)
&& (mCurrentState == -1 || mCurrentState == GSYVideoView.CURRENT_STATE_NORMAL || mCurrentState == GSYVideoView.CURRENT_STATE_ERROR)
) {
mThumbImageViewLayout.visibility = View.VISIBLE
}
@@ -65,19 +64,27 @@ class SimpleCoverVideoPlayer : StandardGSYVideoPlayer {
//加载图片
val requestOptions = RequestOptions()
// .placeholder(R.drawable.tanlu_normal_image)
.error(R.drawable.video_loading)
.error(R.drawable.video_loading_img)
Glide.with(mContext).asBitmap()
.load(url)
.apply(requestOptions)
.into(SkinAbleBitmapTarget(coverImage, requestOptions))
.load(url)
.apply(requestOptions)
.into(SkinAbleBitmapTarget(coverImage, requestOptions))
}
/*
* 默认双击暂停
* */
override fun onClickUiToggle(){
super.touchDoubleUp()
}
override fun updateStartImage() {
when (mCurrentState) {
// GSYVideoView.CURRENT_STATE_PLAYING -> start.setImageResource(R.drawable.selector_bg_btn_pause)
// GSYVideoView.CURRENT_STATE_ERROR -> start.setImageResource(R.drawable.main_video_refresh_btn)
// else -> start.setImageResource(R.drawable.selector_bg_btn_play)
GSYVideoView.CURRENT_STATE_PLAYING -> start.setImageResource(R.drawable.v2x_video_pause)
// GSYVideoView.CURRENT_STATE_ERROR -> start.setImageResource(R.drawable.live_error)
else -> start.setImageResource(R.drawable.v2x_icon_event_play)
}
}
@@ -153,7 +160,7 @@ class SimpleCoverVideoPlayer : StandardGSYVideoPlayer {
start -> {
}
else -> {
else -> {
}
}

View File

@@ -1,4 +1,4 @@
package com.mogo.module.tanlu.video
package com.mogo.module.v2x
import com.shuyu.gsyvideoplayer.GSYVideoManager
import com.shuyu.gsyvideoplayer.cache.CacheFactory

Binary file not shown.

After

Width:  |  Height:  |  Size: 817 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 817 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@@ -1,57 +1,81 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/window_road_video"
android:id="@+id/item_video_cover"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#99000000"
android:paddingStart="@dimen/module_main_v2x_animation_width">
android:layout_height="match_parent">
<com.mogo.module.v2x.view.RoundLayout
android:id="@+id/rlRoadEventList"
<RelativeLayout
android:id="@+id/surface_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/dp_30"
app:roundLayoutRadius="@dimen/dp_28">
android:gravity="center">
<com.mogo.module.v2x.view.TextureVideoView
android:id="@+id/roadVideoView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/live_video_progress_bar_loading_color"
android:clickable="false"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
</RelativeLayout>
</com.mogo.module.v2x.view.TextureVideoView>
<RelativeLayout
android:id="@+id/thumb"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true">
<com.mogo.service.imageloader.MogoImageView
android:id="@+id/thumbnail_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/v2x_bg_big_image_dark"
android:visibility="gone"
android:scaleType="fitXY"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/window_video_play"
android:layout_width="@dimen/dp_100"
android:layout_height="@dimen/dp_100"
android:id="@+id/thumbImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:visibility="gone"
android:src="@drawable/v2x_icon_event_play"/>
</com.mogo.module.v2x.view.RoundLayout>
<ImageView
android:id="@+id/roadVideoClose"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/rlRoadEventList"
android:layout_alignRight="@+id/rlRoadEventList"
android:src="@drawable/v2x_panel_close" />
android:scaleType="centerCrop" />
</RelativeLayout>
</RelativeLayout>
<!--局部播放器-->
<LinearLayout
android:id="@+id/layout_bottom"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_marginBottom="@dimen/dp_260"
android:orientation="horizontal">
<SeekBar
android:id="@+id/progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@null"
android:max="100"
android:maxHeight="@dimen/dp_6"
android:minHeight="@dimen/dp_6"
android:thumb="@null"
android:visibility="gone" />
<ImageView
android:id="@+id/fullscreen"
android:layout_width="60px"
android:layout_height="60px"
android:scaleType="centerInside" />
</LinearLayout>
<ImageView
android:id="@+id/start"
android:layout_width="@dimen/dp_100"
android:layout_height="@dimen/dp_100"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center_vertical"
android:visibility="gone" />
<ProgressBar
android:id="@+id/loading"
android:layout_width="@dimen/dp_56"
android:layout_height="@dimen/dp_56"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:indeterminateDrawable="@drawable/video_loading_bg"
android:visibility="gone" />
</RelativeLayout>

View File

@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00000000"
android:paddingStart="@dimen/module_main_v2x_animation_width">
<com.mogo.module.v2x.view.RoundLayout
android:id="@+id/rlRoadEventList"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_674"
android:layout_marginLeft="@dimen/dp_30"
android:layout_marginTop="@dimen/dp_30"
android:layout_marginRight="@dimen/dp_30"
android:layout_marginBottom="@dimen/dp_327"
android:background="#D9FFFFFF"
app:roundLayoutRadius="@dimen/dp_28">
<com.mogo.module.v2x.view.SimpleCoverVideoPlayer
android:id="@+id/roadVideoView"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_674"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:clickable="true" />
<com.mogo.service.imageloader.MogoImageView
android:id="@+id/thumbnail_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/v2x_bg_big_image_dark"
android:scaleType="fitXY"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/window_video_play"
android:layout_width="@dimen/dp_100"
android:layout_height="@dimen/dp_100"
android:layout_centerInParent="true"
android:src="@drawable/v2x_icon_event_play"
android:visibility="gone" />
<ImageView
android:id="@+id/roadVideoClose"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_20"
android:layout_marginTop="@dimen/dp_20"
android:src="@drawable/v2x_panel_close" />
</com.mogo.module.v2x.view.RoundLayout>
</FrameLayout>