Merge branch 'oi' into dev
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
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;
|
||||
@@ -17,20 +19,26 @@ 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.SimpleCoverVideoPlayer;
|
||||
import com.mogo.utils.BitmapHelper;
|
||||
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.VideoInitKt.initVideo;
|
||||
import static com.shuyu.gsyvideoplayer.utils.GSYVideoType.SCREEN_MATCH_FULL;
|
||||
|
||||
|
||||
/*
|
||||
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 ImageView playImageView;
|
||||
private ImageView thumbnailImage;
|
||||
private ImageView closeImage;
|
||||
|
||||
|
||||
@@ -64,14 +72,76 @@ public class V2XRoadVideoWindow extends RelativeLayout implements IV2XWindow, ID
|
||||
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);
|
||||
//mCurrentAspectRatio
|
||||
// simpleCoverVideoPlayer.
|
||||
|
||||
closeImage = this.findViewById(R.id.roadVideoClose);
|
||||
closeImage.setOnClickListener(v -> {
|
||||
close();
|
||||
});
|
||||
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
|
||||
@@ -86,9 +156,105 @@ public class V2XRoadVideoWindow extends RelativeLayout implements IV2XWindow, ID
|
||||
return;
|
||||
}
|
||||
if (path.contains(".mp4")) {
|
||||
gsyVideoOptionBuilder.setUrl(path).setCacheWithPlay(false).setPlayTag(TAG)
|
||||
.build(simpleCoverVideoPlayer);
|
||||
simpleCoverVideoPlayer.getStartButton().performClick();
|
||||
startPlayWithVideoUrl(path);
|
||||
Bitmap firstbitmap = BitmapHelper.getVideoThumbnail(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");
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ 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
|
||||
@@ -38,7 +37,7 @@ class SimpleCoverVideoPlayer : StandardGSYVideoPlayer {
|
||||
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 -> {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
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 |
@@ -28,8 +28,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/v2x_icon_live_logo"/>
|
||||
android:scaleType="centerCrop" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
@@ -49,10 +48,10 @@
|
||||
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" />
|
||||
android:thumb="@null"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/fullscreen"
|
||||
@@ -63,12 +62,12 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/start"
|
||||
android:layout_width="@dimen/dp_56"
|
||||
android:layout_height="@dimen/dp_56"
|
||||
android:visibility="gone"
|
||||
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:layout_gravity="center_vertical"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/loading"
|
||||
@@ -76,7 +75,7 @@
|
||||
android:layout_height="@dimen/dp_56"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:indeterminateDrawable="@drawable/live_error"
|
||||
android:indeterminateDrawable="@drawable/video_loading_bg"
|
||||
android:visibility="gone" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
@@ -10,19 +10,33 @@
|
||||
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_marginTop="@dimen/dp_30"
|
||||
android:layout_marginRight="@dimen/dp_30"
|
||||
android:layout_marginBottom="@dimen/dp_327"
|
||||
app:roundLayoutRadius="@dimen/dp_28"
|
||||
android:background="#D9FFFFFF">
|
||||
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: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"
|
||||
|
||||
Reference in New Issue
Block a user