Merge branch 'hh' into dev

This commit is contained in:
liujing
2020-10-23 13:43:15 +08:00
7 changed files with 167 additions and 129 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

@@ -1,7 +1,6 @@
package com.mogo.module.v2x.scenario.scene.road;
import android.content.Context;
import android.graphics.Bitmap;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
@@ -15,24 +14,31 @@ 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.utils.BitmapHelper;
import com.mogo.utils.logger.Logger;
import com.mogo.module.v2x.view.SimpleCoverVideoPlayer;
import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder;
import com.shuyu.gsyvideoplayer.utils.GSYVideoType;
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 {
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 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,34 +46,32 @@ 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);
simpleCoverVideoPlayer = this.findViewById(R.id.roadVideoView);
GSYVideoType.setShowType(SCREEN_MATCH_FULL);
//mCurrentAspectRatio
// simpleCoverVideoPlayer.
closeImage = this.findViewById(R.id.roadVideoClose);
closeImage.setOnClickListener(v -> {
close();
});
mVideoView.setOnClickListener(v -> {
mThumbnailImageView.setVisibility(View.GONE);
if (mVideoView.isPlaying()) {
videoPause();
} else {
videoResume();
}
});
}
@Override
@@ -82,68 +86,14 @@ public class V2XRoadVideoWindow extends RelativeLayout implements IV2XWindow, ID
return;
}
if (path.contains(".mp4")) {
videoViewStartWithPath(path);
mVideoView.setOnCompletionListener(mediaPlayer -> {
Logger.w(MODULE_NAME, "视频播放结束...");
videoPlayEnd(path);
});
gsyVideoOptionBuilder.setUrl(path).setCacheWithPlay(false).setPlayTag(TAG)
.build(simpleCoverVideoPlayer);
simpleCoverVideoPlayer.getStartButton().performClick();
}
}
}
/*
* 视频开始播放
* */
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 +116,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,4 +1,4 @@
package com.mogo.module.tanlu.video
package com.mogo.module.v2x.view
import android.content.Context
import android.util.AttributeSet
@@ -34,7 +34,7 @@ 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

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

View File

@@ -1,57 +1,82 @@
<?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"
android:src="@drawable/v2x_icon_live_logo"/>
</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:visibility="gone"
android:maxHeight="@dimen/dp_6"
android:minHeight="@dimen/dp_6"
android:thumb="@null" />
<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_56"
android:layout_height="@dimen/dp_56"
android:visibility="gone"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center_vertical" />
<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/live_error"
android:visibility="gone" />
</RelativeLayout>

View File

@@ -0,0 +1,44 @@
<?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_marginTop="@dimen/dp_30"
android:layout_marginLeft="@dimen/dp_30"
android:layout_marginRight="@dimen/dp_30"
android:layout_marginBottom="@dimen/dp_327"
app:roundLayoutRadius="@dimen/dp_28"
android:background="#D9FFFFFF">
<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"/>
<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>