From d4b1796a967adba01771b6d67dd9123e4fbaf6d1 Mon Sep 17 00:00:00 2001 From: aibingbing Date: Mon, 18 Dec 2023 15:33:47 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=AE=A3=E4=BC=A0=E8=A7=86=E9=A2=91]=20refact?= =?UTF-8?q?or:=20M1=20=E4=B9=98=E5=AE=A2=E5=B1=8F=E5=AE=A3=E4=BC=A0?= =?UTF-8?q?=E8=A7=86=E9=A2=91=20=E5=A2=9E=E5=8A=A0=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E5=8F=AF=E9=85=8D=E7=BD=AE=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E9=80=BB=E8=BE=91=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bean/TaxiPassengerVideoPlay.java | 13 +- .../passenger/ui/video/ConsultVideoPlayer.kt | 4 + .../charter/passenger/ui/video/VideoView.kt | 119 +++++++++++------- .../video/adapter/RecyclerVideoAdapter.java | 32 +++-- app/config/MediaUrlConfig.json | 112 +++++++++++++++++ 5 files changed, 226 insertions(+), 54 deletions(-) diff --git a/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/bean/TaxiPassengerVideoPlay.java b/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/bean/TaxiPassengerVideoPlay.java index dafc61f873..ab3f6db41b 100644 --- a/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/bean/TaxiPassengerVideoPlay.java +++ b/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/bean/TaxiPassengerVideoPlay.java @@ -2,16 +2,19 @@ package com.mogo.och.charter.passenger.bean; public class TaxiPassengerVideoPlay { - public TaxiPassengerVideoPlay(String url, String imageUrl, String title) { + public TaxiPassengerVideoPlay(String url, String imageUrl, String title, int type) { this.url = url; this.imageUrl = imageUrl; this.title = title; + this.type = type; } private String url; private String imageUrl; private String title; + private int type; + public String getTitle() { return title; } @@ -35,4 +38,12 @@ public class TaxiPassengerVideoPlay { public void setImageUrl(String imageUrl) { this.imageUrl = imageUrl; } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } } diff --git a/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/ui/video/ConsultVideoPlayer.kt b/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/ui/video/ConsultVideoPlayer.kt index 27f2b0b76f..166b5fc491 100644 --- a/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/ui/video/ConsultVideoPlayer.kt +++ b/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/ui/video/ConsultVideoPlayer.kt @@ -490,5 +490,9 @@ class ConsultVideoPlayer : StandardGSYVideoPlayer { fun getVideoAllCallBack(): VideoAllCallBack? { return mVideoAllCallBack } + + fun showOrHideStartPlayButton(isShow: Boolean) { + aivStartPlay?.visibility = if (isShow ) View.VISIBLE else View.GONE + } } diff --git a/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/ui/video/VideoView.kt b/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/ui/video/VideoView.kt index 8bf73eda80..6cc77986fd 100644 --- a/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/ui/video/VideoView.kt +++ b/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/ui/video/VideoView.kt @@ -5,12 +5,25 @@ import android.util.AttributeSet import android.view.LayoutInflater import android.view.View import androidx.constraintlayout.widget.ConstraintLayout +import androidx.core.view.isVisible import androidx.recyclerview.widget.RecyclerView import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener +import com.mogo.eagle.core.function.main.MainMoGoApplication import com.mogo.eagle.core.utilcode.kotlin.onClick +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.util.GsonUtils +import com.mogo.eagle.core.utilcode.util.UiThreadHandler import com.mogo.och.charter.passenger.R +import com.mogo.och.charter.passenger.bean.TaxiPassengerVideoPlay import com.mogo.och.charter.passenger.callback.IClearViewCallback import com.mogo.och.charter.passenger.ui.softcontrol.layoutmanage.CarouselLayoutManager +import com.mogo.och.charter.passenger.ui.softcontrol.layoutmanage.CarouselZoomPostLayoutListener +import com.mogo.och.charter.passenger.ui.softcontrol.layoutmanage.CenterScrollListener +import com.mogo.och.charter.passenger.ui.video.adapter.RecyclerVideoAdapter +import com.mogo.och.common.module.wigets.media.IMediaDataSourceListener +import com.mogo.och.common.module.wigets.media.MediaDataSourceManager +import com.mogo.och.common.module.wigets.media.MediaFileCacheManager +import com.mogo.och.common.module.wigets.media.MediaItem import com.shuyu.gsyvideoplayer.video.base.GSYVideoView import kotlinx.android.synthetic.main.charter_p_video_fragment.view.rvVideoPlaylist import kotlin.math.floor @@ -22,27 +35,32 @@ class VideoView @JvmOverloads constructor( ) : ConstraintLayout(context, attrs, defStyleAttr), IMoGoAutopilotStatusListener { companion object { - const val TAG = "DebugView" + const val TAG = "VideoView" } - private val arrayListOf = ArrayList() - var goneViewListener: IClearViewCallback? = null + private val mediaList = mutableListOf() + //新的数据,在view不展示的时候完成新数据更新 + private val mNewMediaList = mutableListOf() + init { LayoutInflater.from(context).inflate(R.layout.charter_p_video_fragment, this, true) onClick { goneViewListener?.goneAllView() } - initConsultData() + initView() + } + + private fun initView() { val carouselLayoutManager = - com.mogo.och.charter.passenger.ui.softcontrol.layoutmanage.CarouselLayoutManager( + CarouselLayoutManager( CarouselLayoutManager.HORIZONTAL, true ) - carouselLayoutManager.setPostLayoutListener(com.mogo.och.charter.passenger.ui.softcontrol.layoutmanage.CarouselZoomPostLayoutListener()) + carouselLayoutManager.setPostLayoutListener(CarouselZoomPostLayoutListener()) carouselLayoutManager.maxVisibleItems = 1 - rvVideoPlaylist.addOnScrollListener(object : com.mogo.och.charter.passenger.ui.softcontrol.layoutmanage.CenterScrollListener() { + rvVideoPlaylist.addOnScrollListener(object : CenterScrollListener() { var prePlayerPosition = 0 override fun pageSelect(recyclerView: RecyclerView?, newState: Int) { //播放视频 @@ -70,7 +88,6 @@ class VideoView @JvmOverloads constructor( player.onVideoPause() } } - }) carouselLayoutManager.addOnDargAutoDiffListener { adapterPosition, currentPosition -> val fl = adapterPosition - floor(adapterPosition) @@ -84,16 +101,16 @@ class VideoView @JvmOverloads constructor( } } val recyclerVideoAdapter = - com.mogo.och.charter.passenger.ui.video.adapter.RecyclerVideoAdapter( + RecyclerVideoAdapter( context, - arrayListOf, + mediaList, rvVideoPlaylist ) recyclerVideoAdapter.setOnThumbImageClilckListener { val (_, player) = getPlayer(carouselLayoutManager) if (player is ConsultVideoPlayer) { player.onVideoReset() - player.thumbImageViewLayout.visibility = View.VISIBLE + player.thumbImageViewLayout.visibility = VISIBLE } rvVideoPlaylist?.smoothScrollToPosition(it) } @@ -104,7 +121,44 @@ class VideoView @JvmOverloads constructor( override fun onAttachedToWindow() { super.onAttachedToWindow() + MediaFileCacheManager.createFileCacheDir(MainMoGoApplication.getApp().applicationContext) + MediaDataSourceManager.init(TAG, object : IMediaDataSourceListener { + override fun onMediaDataSourceChanged(list: List) { + val isNewData = mediaList.isNotEmpty() + CallerLogger.d( + TAG, + "onMediaDataSourceChanged:isNewData=$isNewData, list=${GsonUtils.toJson(list)}" + ) + val localMediaList = mutableListOf() + list.forEach { + val taxiPassengerVideoPlay = TaxiPassengerVideoPlay( + it.fileUrl, + it.coverImageUrl, + it.title, + it.fileType + ) + localMediaList.add(taxiPassengerVideoPlay) + } + if (isNewData) { + if (!isVisible) { + updateMediaListDataAndView(localMediaList) + } else { + mNewMediaList.clear() + mNewMediaList.addAll(localMediaList) + } + } else { + updateMediaListDataAndView(localMediaList) + } + } + }) + } + private fun updateMediaListDataAndView(newList: MutableList) { + mediaList.clear() + mediaList.addAll(newList) + UiThreadHandler.post { + initView() + } } private fun getPlayer(carouselLayoutManager: com.mogo.och.charter.passenger.ui.softcontrol.layoutmanage.CarouselLayoutManager): Pair { @@ -115,6 +169,7 @@ class VideoView @JvmOverloads constructor( } override fun onDetachedFromWindow() { + MediaDataSourceManager.unInit(TAG) super.onDetachedFromWindow() } @@ -133,40 +188,16 @@ class VideoView @JvmOverloads constructor( player.onVideoReset() } } + try { + // 在播放完成的时机更新整体数据 + if (mNewMediaList.isNotEmpty()) { + updateMediaListDataAndView(mNewMediaList) + mNewMediaList.clear() + } + } catch (e: Exception) { + e.printStackTrace() + } } } } - - private fun initConsultData() { - arrayListOf.clear() - arrayListOf.add( - com.mogo.och.charter.passenger.bean.TaxiPassengerVideoPlay( - "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708596763/全车型混剪增加红旗车队.m4v", - "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969511280/车队.png", - "蘑菇车联覆盖生活的方方面面" - ) - ) - arrayListOf.add( - com.mogo.och.charter.passenger.bean.TaxiPassengerVideoPlay( - "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708554279/红旗车队.m4v", - "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969553174/红旗重新排版.png", - "蘑菇车联之红旗车队" - ) - ) - arrayListOf.add( - com.mogo.och.charter.passenger.bean.TaxiPassengerVideoPlay( - "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708499497/大运会合作解说版.m4v", - "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969536177/大运会.png", - "蘑菇车联牵手成都大运会" - ) - ) - arrayListOf.add( - com.mogo.och.charter.passenger.bean.TaxiPassengerVideoPlay( - "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708409810/20210610重新排版3屏.m4v", - "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969579713/三屏.png", - "多视角体验蘑菇车联自动驾驶" - ) - ) - } - } \ No newline at end of file diff --git a/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/ui/video/adapter/RecyclerVideoAdapter.java b/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/ui/video/adapter/RecyclerVideoAdapter.java index 54978cc387..732e4ab38a 100644 --- a/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/ui/video/adapter/RecyclerVideoAdapter.java +++ b/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/ui/video/adapter/RecyclerVideoAdapter.java @@ -10,6 +10,7 @@ import androidx.recyclerview.widget.RecyclerView; import com.bumptech.glide.Glide; import com.bumptech.glide.request.RequestOptions; +import com.mogo.och.common.module.wigets.media.MediaItem; import com.mogo.och.common.module.wigets.toast.ToastCharterUtils; import com.mogo.och.charter.passenger.R; import com.mogo.och.charter.passenger.bean.TaxiPassengerVideoPlay; @@ -62,27 +63,40 @@ public class RecyclerVideoAdapter extends RecyclerView.Adapter { + if (onThumbImageClilckListener != null) { onThumbImageClilckListener.onDxChanged(holder.getAbsoluteAdapterPosition()); } - } - }); + }); + } else { + holder.gsyVideoPlayer.getThumbImageViewLayout().setOnClickListener(null); + } holder.gsyVideoPlayer.setVideoAllCallBack(new GSYSampleCallBack(){ @Override public void onAutoComplete(String url, Object... objects) { diff --git a/app/config/MediaUrlConfig.json b/app/config/MediaUrlConfig.json index fdc8233f54..79a9a68e02 100644 --- a/app/config/MediaUrlConfig.json +++ b/app/config/MediaUrlConfig.json @@ -171,6 +171,34 @@ "title": "多视角体验蘑菇车联自动驾驶" } ] + }, + "charterpassengerochm1": { + "medias": [ + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708596763/全车型混剪增加红旗车队.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969511280/车队.png", + "title": "蘑菇车联覆盖生活的方方面面" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708554279/红旗车队.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969553174/红旗重新排版.png", + "title": "蘑菇车联之红旗车队" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708499497/大运会合作解说版.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969536177/大运会.png", + "title": "蘑菇车联牵手成都大运会" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708409810/20210610重新排版3屏.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969579713/三屏.png", + "title": "多视角体验蘑菇车联自动驾驶" + } + ] } }, "dali": { @@ -345,6 +373,34 @@ "title": "多视角体验蘑菇车联自动驾驶" } ] + }, + "charterpassengerochm1": { + "medias": [ + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708596763/全车型混剪增加红旗车队.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969511280/车队.png", + "title": "蘑菇车联覆盖生活的方方面面" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708554279/红旗车队.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969553174/红旗重新排版.png", + "title": "蘑菇车联之红旗车队" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708499497/大运会合作解说版.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969536177/大运会.png", + "title": "蘑菇车联牵手成都大运会" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708409810/20210610重新排版3屏.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969579713/三屏.png", + "title": "多视角体验蘑菇车联自动驾驶" + } + ] } }, "yantai": { @@ -423,6 +479,34 @@ "title": "多视角体验蘑菇车联自动驾驶" } ] + }, + "charterpassengerochm1": { + "medias": [ + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708596763/全车型混剪增加红旗车队.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969511280/车队.png", + "title": "蘑菇车联覆盖生活的方方面面" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708554279/红旗车队.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969553174/红旗重新排版.png", + "title": "蘑菇车联之红旗车队" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708499497/大运会合作解说版.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969536177/大运会.png", + "title": "蘑菇车联牵手成都大运会" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708409810/20210610重新排版3屏.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969579713/三屏.png", + "title": "多视角体验蘑菇车联自动驾驶" + } + ] } }, "saas": { @@ -597,6 +681,34 @@ "title": "多视角体验蘑菇车联自动驾驶" } ] + }, + "charterpassengerochm1": { + "medias": [ + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708596763/全车型混剪增加红旗车队.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969511280/车队.png", + "title": "蘑菇车联覆盖生活的方方面面" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708554279/红旗车队.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969553174/红旗重新排版.png", + "title": "蘑菇车联之红旗车队" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708499497/大运会合作解说版.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969536177/大运会.png", + "title": "蘑菇车联牵手成都大运会" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708409810/20210610重新排版3屏.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969579713/三屏.png", + "title": "多视角体验蘑菇车联自动驾驶" + } + ] } } }