From bf7ed6ce63ba8fb91a224492aa29f936df4511b2 Mon Sep 17 00:00:00 2001 From: aibingbing Date: Wed, 27 Dec 2023 11:45:56 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=AE=A3=E4=BC=A0=E8=A7=86=E9=A2=91]merge:=20?= =?UTF-8?q?=E5=90=88=E5=B9=B6V5.2.5=E4=BB=A3=E7=A0=81=EF=BC=8C=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E5=9B=A0common=E7=9B=AE=E5=BD=95=E7=BB=93=E6=9E=84?= =?UTF-8?q?=E6=94=B9=E5=8F=98=E5=B8=A6=E6=9D=A5=E7=9A=84=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bus/passenger/MogoOCHBusPassenger.java | 107 +++ .../bus/passenger/MogoOCHShuttlePassenger.kt | 6 +- .../passenger/presenter/PM2VideoPresenter.kt | 7 - .../passenger/passenger/ui/PM2BaseFragment.kt | 12 +- .../passenger/ui/video/PM2VideoFragment.kt | 64 -- .../ui/widget/video/AdvanceGSYVideoPlayer.kt | 137 ---- .../ui/widget/video/AdvanceImageView.kt | 45 -- .../ui/widget/video/AdvancePagerAdapter.kt | 212 ------ .../ui/widget/video/AdvanceVideoView.kt | 254 ------- .../ui/widget/video/AdvanceViewPager.kt | 24 - .../ui/widget/video/ImageAndVideoRotation.kt | 50 -- .../res/m2/layout/bus_p_m2_video_fragment.xml | 13 - .../res/m2/layout/bus_p_m2_video_view.xml | 8 - .../bean/TaxiPassengerVideoPlay.java | 13 +- .../passenger/ui/video/ConsultVideoPlayer.kt | 18 +- .../charter/passenger/ui/video/VideoView.kt | 121 +-- .../video/adapter/RecyclerVideoAdapter.java | 34 +- .../common/src/main/AndroidManifest.xml | 3 +- .../module/biz/constant/OchCommonConst.kt | 6 + .../och/common/module/utils/FileUtils.java | 178 +++++ .../common/module/wigets/media/MediaBean.kt | 23 + .../wigets/media/MediaDataSourceManager.kt | 278 +++++++ .../wigets/media/MediaFileCacheManager.kt | 88 +++ .../module/wigets/media/MediaLoopPlayView.kt | 311 ++++++++ .../module/wigets/media/MediaPlayLogger.kt | 44 ++ .../MediaPlayerActivity.kt} | 6 +- .../wigets/media/MediaPlayerCustomView.kt | 380 ++++++++++ .../wigets/media/MediaPlayerFragment.kt | 75 ++ .../common/module/wigets/video/AdsDatas.kt | 10 - .../wigets/video/ImageVideoRotationView.kt | 44 -- .../wigets/video/VideoPlayerFragment.kt | 62 -- .../module/wigets/video/VideoPlayerView.kt | 589 --------------- .../main/res/layout/fragment_video_player.xml | 4 +- .../passenger/MogoOCHShuttlePassenger.kt | 4 +- .../passenger/presenter/PM2VideoPresenter.kt | 7 - .../shuttle/passenger/ui/PM2BaseFragment.kt | 12 +- .../passenger/ui/video/PM2VideoFragment.kt | 64 -- .../ui/widget/video/AdvanceGSYVideoPlayer.kt | 137 ---- .../ui/widget/video/AdvanceImageView.kt | 45 -- .../ui/widget/video/AdvancePagerAdapter.kt | 211 ------ .../ui/widget/video/AdvanceVideoView.kt | 254 ------- .../ui/widget/video/AdvanceViewPager.kt | 24 - .../ui/widget/video/ImageAndVideoRotation.kt | 49 -- .../shuttle_p_m2_driving_info_fragment.xml | 2 +- .../och/sweepercloud/SweeperProvider.java | 0 .../com/mogo/och/sweeper/SweeperProvider.java | 0 .../passenger/bean/TaxiPassengerVideoPlay.kt | 2 +- .../taxi/passenger/ui/video/InfoVideoView.kt | 114 +-- .../ui/video/RecyclerVideoAdapter.java | 40 +- .../passenger/widget/ConsultVideoPlayer.kt | 19 +- app/build.gradle | 17 +- app/config/MediaUrlConfig.json | 714 ++++++++++++++++++ app/config/tempConfig.json | 490 ------------ .../mogo/launcher/startup/ConfigStartUp.kt | 4 +- .../core/data/config/FunctionBuildConfig.kt | 5 +- 55 files changed, 2490 insertions(+), 2950 deletions(-) create mode 100644 OCH/bus/passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/MogoOCHBusPassenger.java delete mode 100644 OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/presenter/PM2VideoPresenter.kt delete mode 100644 OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/ui/video/PM2VideoFragment.kt delete mode 100644 OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/ui/widget/video/AdvanceGSYVideoPlayer.kt delete mode 100644 OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/ui/widget/video/AdvanceImageView.kt delete mode 100644 OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/ui/widget/video/AdvancePagerAdapter.kt delete mode 100644 OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/ui/widget/video/AdvanceVideoView.kt delete mode 100644 OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/ui/widget/video/AdvanceViewPager.kt delete mode 100644 OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/ui/widget/video/ImageAndVideoRotation.kt delete mode 100644 OCH/bus/passenger/src/main/res/m2/layout/bus_p_m2_video_fragment.xml delete mode 100644 OCH/bus/passenger/src/main/res/m2/layout/bus_p_m2_video_view.xml create mode 100644 OCH/common/common/src/main/java/com/mogo/och/common/module/utils/FileUtils.java create mode 100644 OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/media/MediaBean.kt create mode 100644 OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/media/MediaDataSourceManager.kt create mode 100644 OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/media/MediaFileCacheManager.kt create mode 100644 OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/media/MediaLoopPlayView.kt create mode 100644 OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayLogger.kt rename OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/{video/VideoPlayerActivity.kt => media/MediaPlayerActivity.kt} (78%) create mode 100644 OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayerCustomView.kt create mode 100644 OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayerFragment.kt delete mode 100644 OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/video/AdsDatas.kt delete mode 100644 OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/video/ImageVideoRotationView.kt delete mode 100644 OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerFragment.kt delete mode 100644 OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerView.kt delete mode 100644 OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/presenter/PM2VideoPresenter.kt delete mode 100644 OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/ui/video/PM2VideoFragment.kt delete mode 100644 OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/ui/widget/video/AdvanceGSYVideoPlayer.kt delete mode 100644 OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/ui/widget/video/AdvanceImageView.kt delete mode 100644 OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/ui/widget/video/AdvancePagerAdapter.kt delete mode 100644 OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/ui/widget/video/AdvanceVideoView.kt delete mode 100644 OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/ui/widget/video/AdvanceViewPager.kt delete mode 100644 OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/ui/widget/video/ImageAndVideoRotation.kt delete mode 100644 OCH/sweeper/sweeper-cloud/src/main/java/com/mogo/och/sweepercloud/SweeperProvider.java delete mode 100644 OCH/sweeper/sweeper/src/main/java/com/mogo/och/sweeper/SweeperProvider.java create mode 100644 app/config/MediaUrlConfig.json delete mode 100644 app/config/tempConfig.json diff --git a/OCH/bus/passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/MogoOCHBusPassenger.java b/OCH/bus/passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/MogoOCHBusPassenger.java new file mode 100644 index 0000000000..bd4d139df7 --- /dev/null +++ b/OCH/bus/passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/MogoOCHBusPassenger.java @@ -0,0 +1,107 @@ +package com.mogo.och.bus.passenger; + +import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS_P; + +import android.content.Context; + +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentActivity; +import androidx.fragment.app.FragmentManager; + +import com.alibaba.android.arouter.facade.annotation.Route; +import com.mogo.eagle.core.data.config.FunctionBuildConfig; +import com.mogo.eagle.core.function.call.setting.CallerMoGoUiSettingManager; +import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils; +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; +import com.mogo.eagle.core.utilcode.util.MultiDisplayUtils; +import com.mogo.och.bus.passenger.constant.BusPassengerConst; +import com.mogo.och.bus.passenger.ui.BusPassengerRouteFragment; +import com.mogo.och.common.module.wigets.media.MediaPlayerActivity; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * 网约车-Bus-乘客端 + * + * Created on 2022/3/29 + */ +@Route(path = BusPassengerConst.PATH) +public class MogoOCHBusPassenger implements IMogoOCH { + private static final String TAG = MogoOCHBusPassenger.class.getSimpleName(); + + private FragmentActivity mActivity; + private int mContainerId; + private BusPassengerRouteFragment mPassengerFragment; + + @Override + public void createCoverage(FragmentActivity activity, int containerId) { + + } + + @Nullable + @Override + public Fragment createCoverage(@Nullable FragmentActivity activity, @Nullable Integer containerId) { + this.mActivity = activity; + this.mContainerId = containerId; + showFragment(); + + if (AppIdentityModeUtils.isJL(FunctionBuildConfig.appIdentityMode) && activity != null) { + MultiDisplayUtils.INSTANCE.startActWithSecond(activity, MediaPlayerActivity.class); + } + + return null; + } + + @NotNull + @Override + public String getFunctionName() { + return TAG; + } + + @Override + public void onDestroy() { + // 若不调用finish, 设置中打开关闭UITouch,会造成och fragment 重叠 + if (mActivity == null) return; + mActivity.finish(); + } + + @Override + public void init(Context context) { + } + + /** + * 进入鹰眼模式,设置手势缩放地图失效 + */ + private void stepIntoVrMode() { + CallerLogger.d( M_BUS_P + TAG, "进入vr模式" ); + CallerMoGoUiSettingManager.INSTANCE.stepInDayMode();//白天模式 状态栏字体颜色变黑 + } + + private void showFragment() { + FragmentManager supportFragmentManager = mActivity.getSupportFragmentManager(); + if(mPassengerFragment == null){ + CallerLogger.d(M_BUS_P + TAG, "准备add fragment======"); + Fragment fragmentByTag = supportFragmentManager.findFragmentByTag(BusPassengerRouteFragment.TAG); + if (fragmentByTag instanceof BusPassengerRouteFragment){ + mPassengerFragment = (BusPassengerRouteFragment)fragmentByTag; + }else { + mPassengerFragment = new BusPassengerRouteFragment(); + } + if (!mPassengerFragment.isAdded()){ + supportFragmentManager.beginTransaction().add(mContainerId, mPassengerFragment,BusPassengerRouteFragment.TAG).commitAllowingStateLoss(); + } + return; + } + + CallerLogger.d(M_BUS_P + TAG, "准备show fragment"); + supportFragmentManager.beginTransaction().show(mPassengerFragment).commitAllowingStateLoss(); + } + + private void hideFragment(){ + if (mPassengerFragment != null){ + mActivity.getSupportFragmentManager().beginTransaction().hide(mPassengerFragment).commitAllowingStateLoss(); + } + } + +} diff --git a/OCH/bus/passenger/src/main/java/com/mogo/och/bus/passenger/MogoOCHShuttlePassenger.kt b/OCH/bus/passenger/src/main/java/com/mogo/och/bus/passenger/MogoOCHShuttlePassenger.kt index adc783206e..d58e235823 100644 --- a/OCH/bus/passenger/src/main/java/com/mogo/och/bus/passenger/MogoOCHShuttlePassenger.kt +++ b/OCH/bus/passenger/src/main/java/com/mogo/och/bus/passenger/MogoOCHShuttlePassenger.kt @@ -13,9 +13,9 @@ import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant import com.mogo.eagle.core.utilcode.util.MultiDisplayUtils import com.mogo.och.bus.passenger.constant.BusPassengerConst -import com.mogo.och.bus.passenger.passenger.ui.PM2BaseFragment import com.mogo.och.bus.passenger.ui.BusPassengerRouteFragment -import com.mogo.och.common.module.wigets.video.VideoPlayerActivity +import com.mogo.och.bus.passenger.passenger.ui.PM2BaseFragment +import com.mogo.och.common.module.wigets.media.MediaPlayerActivity /** * 网约车-Bus-乘客端 @@ -34,7 +34,7 @@ class MogoOCHShuttlePassenger : IMoGoFunctionProvider { showFragment() if (AppIdentityModeUtils.isJL(FunctionBuildConfig.appIdentityMode)) { mActivity?.let { - MultiDisplayUtils.startActWithSecond(it, VideoPlayerActivity::class.java) + MultiDisplayUtils.startActWithSecond(it, MediaPlayerActivity::class.java) } } return null diff --git a/OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/presenter/PM2VideoPresenter.kt b/OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/presenter/PM2VideoPresenter.kt deleted file mode 100644 index 0407807008..0000000000 --- a/OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/presenter/PM2VideoPresenter.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.mogo.och.bus.passenger.passenger.presenter - -import com.mogo.commons.mvp.Presenter -import com.mogo.och.bus.passenger.passenger.ui.video.PM2VideoFragment - -class PM2VideoPresenter(view: PM2VideoFragment?) : - Presenter(view) \ No newline at end of file diff --git a/OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/ui/PM2BaseFragment.kt b/OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/ui/PM2BaseFragment.kt index ff1a90270f..8a0a0d62c9 100644 --- a/OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/ui/PM2BaseFragment.kt +++ b/OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/ui/PM2BaseFragment.kt @@ -3,7 +3,7 @@ package com.mogo.och.bus.passenger.passenger.ui import com.mogo.commons.mvp.MvpFragment import com.mogo.och.bus.passenger.R import com.mogo.och.bus.passenger.passenger.presenter.PM2Presenter -import com.mogo.och.bus.passenger.passenger.ui.video.PM2VideoFragment +import com.mogo.och.common.module.wigets.media.MediaPlayerFragment /** * @author: wangmingjun @@ -14,7 +14,7 @@ class PM2BaseFragment : private var drivingFragment : PM2DrivingInfoFragment? = null private var hdMapFragment : PM2HPMapFragment? = null - private var videoFragment : PM2VideoFragment? = null + private var mediaFragment : MediaPlayerFragment? = null override fun getLayoutId(): Int { return R.layout.bus_p_m2_fragment @@ -55,9 +55,9 @@ class PM2BaseFragment : childFragmentManager.beginTransaction().add(R.id.hd_map_fragment, hdMapFragment!!) .show(hdMapFragment!!).commitAllowingStateLoss() - if (videoFragment == null) videoFragment = PM2VideoFragment() - childFragmentManager.beginTransaction().add(R.id.video_fragment, videoFragment!!) - .show(videoFragment!!).commitAllowingStateLoss() + if (mediaFragment == null) mediaFragment = MediaPlayerFragment() + childFragmentManager.beginTransaction().add(R.id.video_fragment, mediaFragment!!) + .show(mediaFragment!!).commitAllowingStateLoss() } override fun createPresenter(): PM2Presenter { @@ -65,6 +65,6 @@ class PM2BaseFragment : } companion object { - public val TAG = PM2BaseFragment::class.java.simpleName + val TAG = PM2BaseFragment::class.java.simpleName } } \ No newline at end of file diff --git a/OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/ui/video/PM2VideoFragment.kt b/OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/ui/video/PM2VideoFragment.kt deleted file mode 100644 index 7459c52dc5..0000000000 --- a/OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/ui/video/PM2VideoFragment.kt +++ /dev/null @@ -1,64 +0,0 @@ -package com.mogo.och.bus.passenger.passenger.ui.video - -import com.google.gson.reflect.TypeToken -import com.mogo.commons.mvp.MvpFragment -import com.mogo.eagle.core.data.config.FunctionBuildConfig -import com.mogo.eagle.core.utilcode.util.GsonUtils -import com.mogo.och.bus.passenger.R -import com.mogo.och.bus.passenger.passenger.presenter.PM2VideoPresenter -import com.mogo.och.common.module.wigets.video.AdsDatas -import com.mogo.och.common.module.wigets.video.RotationItem -import kotlinx.android.synthetic.main.bus_p_m2_video_fragment.imageVideoRotationView - -/** - * @author: wangmingjun - * @date: 2022/4/12 - */ -class PM2VideoFragment : - MvpFragment() { - - private var arrayListOf = mutableListOf() - - override fun getLayoutId(): Int { - return R.layout.bus_p_m2_video_fragment - } - - - override fun createPresenter(): PM2VideoPresenter { - return PM2VideoPresenter(this) - } - - companion object { - private val TAG = PM2VideoFragment::class.java.simpleName - } - - override fun getTagName(): String { - return TAG - } - - override fun initViews() { - initResourceData() - imageVideoRotationView.setData(arrayListOf) - } - - override fun onPause() { - super.onPause() - imageVideoRotationView.setPause() - } - - override fun onResume() { - super.onResume() - imageVideoRotationView.setResume() - } - - private fun initResourceData() { - - try { - arrayListOf.clear() - var datas: AdsDatas = GsonUtils.fromJson(FunctionBuildConfig.tempConfig,object : TypeToken() {}.type) - arrayListOf.addAll(datas.ads) - } catch (e: Exception) { - e.printStackTrace() - } - } -} \ No newline at end of file diff --git a/OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/ui/widget/video/AdvanceGSYVideoPlayer.kt b/OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/ui/widget/video/AdvanceGSYVideoPlayer.kt deleted file mode 100644 index 8fe325db3e..0000000000 --- a/OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/ui/widget/video/AdvanceGSYVideoPlayer.kt +++ /dev/null @@ -1,137 +0,0 @@ -package com.mogo.och.bus.passenger.passenger.ui.widget.video - -import android.content.Context -import android.media.AudioManager -import android.util.AttributeSet -import com.mogo.eagle.core.utilcode.mogo.logger.Logger -import com.mogo.eagle.core.widget.media.video.TextureVideoViewOutlineProvider -import com.shuyu.gsyvideoplayer.utils.GSYVideoType -import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer -import me.jessyan.autosize.utils.AutoSizeUtils - -/** - * @author: wangmingjun - * @date: 2023/2/17 - * 隐藏所有控件的player - */ -class AdvanceGSYVideoPlayer: StandardGSYVideoPlayer { - constructor(context: Context?) : super(context) - constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) - - init { - hideWidget() - GSYVideoType.setShowType(GSYVideoType.SCREEN_TYPE_16_9) - GSYVideoType.setRenderType(GSYVideoType.GLSURFACE) - } - - override fun hideAllWidget() { - Logger.d(ImageAndVideoRotation.TAG, "hideAllWidget") -// hideWidget() - } - - override fun changeUiToNormal() { - Logger.d(ImageAndVideoRotation.TAG, "changeUiToNormal-hide") - hideWidget() - } - - override fun changeUiToPreparingShow() { - Logger.d(ImageAndVideoRotation.TAG, "changeUiToPreparingShow-hide") - hideWidget() - } - - override fun changeUiToPlayingShow() { - Logger.d(ImageAndVideoRotation.TAG, "changeUiToPlayingShow") - setCacheImageViewGone() - } - - override fun changeUiToPauseShow() { - Logger.d(ImageAndVideoRotation.TAG, "changeUiToPauseShow-hide") - startPlayLogic() -// hideWidget() - } - - override fun changeUiToCompleteShow() { - Logger.d(ImageAndVideoRotation.TAG, "changeUiToCompleteShow") - setCacheImageViewGone() - } - - override fun changeUiToPlayingBufferingShow() { - Logger.d(ImageAndVideoRotation.TAG, "changeUiToPlayingBufferingShow -hide") - hideWidget() - } - - override fun changeUiToError() { - Logger.d(ImageAndVideoRotation.TAG, "changeUiToError-hide") - hideWidget() - } - - private fun hideWidget(){ - setViewShowState(mBottomContainer, INVISIBLE) - setViewShowState(mProgressBar, INVISIBLE) - setViewShowState(mCurrentTimeTextView, INVISIBLE) - setViewShowState(mTotalTimeTextView, INVISIBLE) - setViewShowState(mBottomProgressBar, INVISIBLE) - setViewShowState(mBackButton, INVISIBLE) - setViewShowState(mStartButton, INVISIBLE) - - setViewShowState(mThumbImageViewLayout, VISIBLE) - setViewShowState(mThumbImageView, VISIBLE) - - setViewShowState(mTopContainer, INVISIBLE) - - setViewShowState(mLoadingProgressBar, INVISIBLE) - setViewShowState( - mLockScreen, INVISIBLE - ) - - setIsTouchWiget(false) - isFocusableInTouchMode = false - } - - fun setCacheImageViewVisible() { - Logger.d(ImageAndVideoRotation.TAG, "CacheImageViewVISIBLE") - setViewShowState(mThumbImageViewLayout, VISIBLE) -// setViewShowState(mThumbImageView, VISIBLE) - } - - fun setCacheImageViewGone() { - Logger.d(ImageAndVideoRotation.TAG, "CacheImageViewGONE") - setViewShowState(mThumbImageViewLayout, INVISIBLE) -// setViewShowState(mThumbImageView, INVISIBLE) - } - - //失去焦点声音压低 - override fun onLossTransientCanDuck() { -// setStreamVolume(0.2f) - setNeedMute(true) - } - - //获取焦点声音恢复 - override fun onGankAudio() { -// setStreamVolume(5.0f) - setNeedMute(false) - } - - private fun setStreamVolume(percent: Float){ - var mAudioManager = mContext?.getSystemService(Context.AUDIO_SERVICE) as AudioManager - var maxVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC) - var volume = (percent * maxVolume).toInt() - if (volume < 0 ){ - volume = 0 - } - mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC,volume,0) - } - - private fun setNeedMute(isMute: Boolean){ - gsyVideoManager?.player?.setNeedMute(isMute) - } - - override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { - super.onSizeChanged(w, h, oldw, oldh) - if (!mIfCurrentIsFullscreen) { - val dp2px = AutoSizeUtils.dp2px(context, 16f) - this.outlineProvider = TextureVideoViewOutlineProvider(dp2px.toFloat()) - this.clipToOutline = true - } - } -} \ No newline at end of file diff --git a/OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/ui/widget/video/AdvanceImageView.kt b/OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/ui/widget/video/AdvanceImageView.kt deleted file mode 100644 index 6ec0d9d997..0000000000 --- a/OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/ui/widget/video/AdvanceImageView.kt +++ /dev/null @@ -1,45 +0,0 @@ -package com.mogo.och.bus.passenger.passenger.ui.widget.video - -import android.annotation.SuppressLint -import android.content.Context -import android.util.AttributeSet -import android.widget.ImageView -import android.widget.RelativeLayout -import com.bumptech.glide.Glide -import com.bumptech.glide.request.RequestOptions -import com.mogo.och.bus.passenger.R - -/** - * @author: wangmingjun - * @date: 2023/2/6 - */ -class AdvanceImageView @JvmOverloads constructor( - context: Context, attrs: AttributeSet? = null -) : RelativeLayout(context, attrs) { - - private var imageView: ImageView? = null - - init { - initView() - } - - private fun initView() { - imageView = ImageView(context) - imageView?.scaleType = ImageView.ScaleType.FIT_XY - addView(imageView, LayoutParams(-1, -1)) - } - - @SuppressLint("CheckResult") - fun setImagePath(path: String){ - imageView?.setImageResource(R.drawable.bus_p_m2_p_video_holder) - imageView?.let { Glide.with(context).asBitmap().load(path) - .apply( - RequestOptions().useUnlimitedSourceGeneratorsPool(true) - .placeholder(R.drawable.bus_p_m2_p_video_holder) - .error(R.drawable.bus_p_m2_p_video_holder) - .fallback(R.drawable.bus_p_m2_p_video_holder) - .centerCrop() - ) - .into(it) } - } -} \ No newline at end of file diff --git a/OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/ui/widget/video/AdvancePagerAdapter.kt b/OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/ui/widget/video/AdvancePagerAdapter.kt deleted file mode 100644 index 422bb1aa15..0000000000 --- a/OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/ui/widget/video/AdvancePagerAdapter.kt +++ /dev/null @@ -1,212 +0,0 @@ -package com.mogo.och.bus.passenger.passenger.ui.widget.video - -import android.content.Context -import android.view.View -import android.view.ViewGroup -import androidx.viewpager.widget.PagerAdapter -import androidx.viewpager.widget.ViewPager -import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d -import com.mogo.eagle.core.utilcode.mogo.logger.Logger -import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant -import com.mogo.eagle.core.utilcode.util.CountDownTimer -import com.mogo.och.common.module.wigets.video.RotationItem -import com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack - -/** - * @author: wangmingjun - * @date: 2023/2/6 - */ -class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter(), - ViewPager.OnPageChangeListener { - - private val mContext: Context = context - private val mViewPager: ViewPager = viewPager - - private var dataList = mutableListOf() - private var viewList = mutableListOf() - - private var lastPosition = -1 - - private var current = 0 - private val time = 5000 - private var pause = false - private var countDownTimer: CountDownTimer? = null - - fun setData(list: MutableList) { - if (list.isEmpty()) return - dataList.addAll(list) - - viewList.clear() - - list.forEach { - addView(it) - } - - mViewPager.addOnPageChangeListener(this) - - notifyDataSetChanged() - - mViewPager.currentItem = 0 - - if (viewList.size > 0) { - if (viewList[mViewPager.currentItem] is AdvanceVideoView) {//有人反应第一个是视频不播放这边优化了一下 - Logger.d(ImageAndVideoRotation.TAG, "第一个是视频") - val video = viewList[mViewPager.currentItem] as AdvanceVideoView - video.setVideo(gsySampleCallBack) - - } else if (viewList[mViewPager.currentItem] is AdvanceImageView) { - Logger.d(ImageAndVideoRotation.TAG, "startTimer()_1") - current = 0//换页重新计算时间 - startTimer() - } - } - } - - override fun getCount(): Int { - return dataList.size - } - - override fun isViewFromObject(view: View, `object`: Any): Boolean { - return view === `object` - } - - override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) { - container.removeView(viewList[position]) - } - - override fun instantiateItem(container: ViewGroup, position: Int): Any { - val view: View = viewList[position] - container.addView(view) - return view - - } - - override fun getItemPosition(`object`: Any): Int { - return POSITION_NONE - } - - private fun addView(item: RotationItem) { - if (item.type == 1) { // 表示视频 - val videoView = AdvanceVideoView(mContext) - videoView.setVideoPath(item.path,item.cacheImgPath) - viewList.add(videoView) - } else { // 表示图片 - val imageView = AdvanceImageView(mContext) - imageView.setImagePath(item.path) - viewList.add(imageView) - } - } - - fun setPause() { - pause = true - if (viewList.size > 0 && viewList[mViewPager.currentItem] is AdvanceVideoView) { - val videoView = viewList[mViewPager.currentItem] as AdvanceVideoView - videoView.setPause() - } - } - - fun setResume() { - pause = false - if (viewList.size > 0 && viewList[mViewPager.currentItem] is AdvanceVideoView) { - val videoView = viewList[mViewPager.currentItem] as AdvanceVideoView - videoView.setResume() - } - } - - override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) { - } - - override fun onPageSelected(position: Int) { - } - - override fun onPageScrollStateChanged(state: Int) { - // 由于viewpager的预加载机制onPageSelected这里面加载videoview 放的跟玩一样 等操作完成后再播放videoview就香了 很丝滑 - if (state == 0) { //静止,什么都没做 - val currentItem = mViewPager.currentItem - Logger.d( - ImageAndVideoRotation.TAG, - "state = $state currentItem = $currentItem lastPosition = $lastPosition") - - if (viewList.size > 1) { //多于1,才会循环跳转 - - if (viewList[mViewPager.currentItem] is AdvanceVideoView) { - - val videoView = (viewList[mViewPager.currentItem] as AdvanceVideoView) - videoView.setCacheImageViewVisible() - videoView.setVideo(gsySampleCallBack) - - } else if (viewList[mViewPager.currentItem] is AdvanceImageView) { - Logger.d(ImageAndVideoRotation.TAG, "startTimer()") - current = 0//换页重新计算时间 - startTimer() - } - lastPosition = mViewPager.currentItem - } - } - } - - private var gsySampleCallBack = object : GSYSampleCallBack() { - - override fun onPrepared(url: String?, vararg objects: Any?) { - Logger.d(ImageAndVideoRotation.TAG, "onPrepared--$url") - } - - override fun onAutoComplete(url: String?, vararg objects: Any?) { - Logger.d(ImageAndVideoRotation.TAG, "onAutoComplete()-$url") - if (viewList[mViewPager.currentItem] is AdvanceVideoView){ - val videoView = (viewList[mViewPager.currentItem] as AdvanceVideoView) - if (viewList.size == 1){ - videoView.startPlay(url) - }else{ - videoView.onVideoReset() - goNextItemView() - } - } - } - - override fun onPlayError(url: String?, vararg objects: Any?) { - super.onPlayError(url, *objects) - Logger.d(ImageAndVideoRotation.TAG, "onPlayError()-$url") - if (viewList[mViewPager.currentItem] is AdvanceVideoView){ - val videoView = (viewList[mViewPager.currentItem] as AdvanceVideoView) - videoView.onVideoReset() -// videoView.setCacheImageViewVisible() - videoView.clearLocalErrorVideo() - goNextItemView() - } - } - } - - private fun startTimer() { - if (countDownTimer != null){ - countDownTimer?.cancel() - countDownTimer = null - } - countDownTimer = object : CountDownTimer(5000,1000){ - override fun onTick(millisUntilFinished: Long) { - d(SceneConstant.M_BUS_P + "startTimer", "倒计时秒 = ${millisUntilFinished/1000}" ) - } - - override fun onFinish() { - d(ImageAndVideoRotation.TAG + "startTimer", "5s到,跳转") - goNextItemView() - } - - }.start() - } - - /** - * view 跳转 - */ - private fun goNextItemView() { - if (mViewPager.currentItem == viewList.size - 1) {//已经到最后一个 - mViewPager.post { - mViewPager.setCurrentItem(0, true) - } - } else { - mViewPager.post { - mViewPager.setCurrentItem(mViewPager.currentItem + 1, true) - } - } - } -} \ No newline at end of file diff --git a/OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/ui/widget/video/AdvanceVideoView.kt b/OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/ui/widget/video/AdvanceVideoView.kt deleted file mode 100644 index f6bc20e3cd..0000000000 --- a/OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/ui/widget/video/AdvanceVideoView.kt +++ /dev/null @@ -1,254 +0,0 @@ -package com.mogo.och.bus.passenger.passenger.ui.widget.video - -import android.annotation.SuppressLint -import android.content.Context -import android.net.Uri -import android.util.AttributeSet -import android.widget.ImageView -import android.widget.RelativeLayout -import com.mogo.eagle.core.utilcode.download.* -import com.mogo.eagle.core.utilcode.download.callback.* -import com.mogo.eagle.core.utilcode.mogo.logger.Logger -import com.mogo.eagle.core.utilcode.util.FileUtils -import com.mogo.eagle.core.utilcode.util.ThreadUtils -import com.mogo.eagle.core.utilcode.util.UiThreadHandler -import com.mogo.och.bus.passenger.R -import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder -import com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack -import java.io.File - -/** - * @author: wangmingjun - * @date: 2023/2/8 - */ -class AdvanceVideoView @JvmOverloads constructor( - context: Context, attrs: AttributeSet? = null -) : RelativeLayout(context, attrs) { - - private var videoRelativeLayout: RelativeLayout? = null - private var cacheImage: ImageView? = null - - private var videoViewPlayer: AdvanceGSYVideoPlayer? = null - private var gsyVideoOptionBuilder: GSYVideoOptionBuilder? = null - private var mOnCompletionListener: GSYSampleCallBack? = null - private var downloadVideoName = "" - private var fileNetPath: String? = "" - private var cacheImageUrl: String? = "" - private var mVideoDirPath: String? = "" - - init { - mVideoDirPath = context.filesDir.absolutePath + File.separator + "video" + File.separator -// mVideoDirPath = Config.downLoadPath - initView() - } - - private fun initView() { - initVideoView() - initCacheImgView() - } - - private fun initCacheImgView() { - cacheImage = ImageView(context) - cacheImage?.scaleType = ImageView.ScaleType.FIT_XY -// addView(cacheImage, LayoutParams(-1, -1)) - } - - private fun initVideoView() { - videoRelativeLayout = RelativeLayout(context) - val outLayout = LayoutParams(-1, -1) - addView(videoRelativeLayout, outLayout) - - if (videoViewPlayer === null) { - //视频播放控件 - videoViewPlayer = AdvanceGSYVideoPlayer(context) - } - - val layoutParams = LayoutParams(-1, -1) - //设置videoview占满父view播放 - layoutParams.addRule(ALIGN_PARENT_LEFT) - layoutParams.addRule(ALIGN_PARENT_RIGHT) - layoutParams.addRule(ALIGN_PARENT_TOP) - layoutParams.addRule(ALIGN_PARENT_BOTTOM) - - videoRelativeLayout?.addView(videoViewPlayer, layoutParams) - } - - fun setVideoPath(path: String, cacheImageUrl: String) { - // https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357834634/5.m4v - // https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360274126/10.mp4 - this.fileNetPath = path - this.cacheImageUrl = cacheImageUrl - val pathList = path.split("/") - if (pathList.isNotEmpty()) { - this.downloadVideoName = pathList[pathList.size - 1] - } - } - - private fun loadCacheImg() { - // BitmapHelper.getVideoThumbnail(path) /*获取第一帧图* -// OCHThreadPoolManager.getsInstance().execute { -// var bitmap = BitmapHelper.getVideoThumbnail(fileNetPath) - Logger.d(ImageAndVideoRotation.TAG, "setVideoPath") -// ThreadUtils.runOnUiThread { -// Logger.d(ImageAndVideoRotation.TAG, "bitmap加载") - cacheImage?.setImageResource(R.drawable.bus_p_m2_p_video_holder) -// cacheImage?.let { //暂时去掉加载首帧图,加载视频时,用本地默认图 -// Glide.with(context).asBitmap().load(cacheImageUrl) -// .apply( -// RequestOptions().useUnlimitedSourceGeneratorsPool(true) -// .placeholder(R.drawable.m2_p_video_holder) -// .error(R.drawable.m2_p_video_holder) -// .fallback(R.drawable.m2_p_video_holder) -// .centerCrop() -// ) -// .into(it) -// } - videoViewPlayer?.thumbImageView = cacheImage -// setCacheImageViewVisible() -// } -// } - } - - fun clearLocalErrorVideo() { - if (downloadVideoName.isNotEmpty() - && FileUtils.isFileExists(mVideoDirPath + downloadVideoName) - ) { - FileUtils.delete(mVideoDirPath + downloadVideoName) - } - } - - @SuppressLint("CheckResult") - fun setCacheImageViewVisible() { - UiThreadHandler.post { -// cacheImage?.visibility = VISIBLE - videoViewPlayer?.setCacheImageViewVisible() - } - } - - fun setCacheImageViewGone() { - UiThreadHandler.post { -// cacheImage?.visibility = GONE - videoViewPlayer?.setCacheImageViewGone() - } - - } - - fun setVideo(onCompletionListener: GSYSampleCallBack) { - loadCacheImg() - Logger.d(ImageAndVideoRotation.TAG, "setVideo") - mOnCompletionListener = onCompletionListener - //判断是否已经下载 - if (downloadVideoName.isNotEmpty()) { - Logger.d( - ImageAndVideoRotation.TAG, - "video local url = $mVideoDirPath$downloadVideoName" - ) - if (FileUtils.isFileExists(mVideoDirPath + downloadVideoName)) { - Logger.d(ImageAndVideoRotation.TAG, "have cache startPlay") - startPlay(Uri.fromFile(File(mVideoDirPath + downloadVideoName)).toString()) - return - } - startDownLoadVideo() - } - } - - private fun startDownLoadVideo() { - //下载视频, 下载成功后再播放 - Logger.d(ImageAndVideoRotation.TAG, "startDownLoadVideo") - FileUtils.createFileDir(mVideoDirPath) - val downloadUrl = fileNetPath - val downloadDir = mVideoDirPath - if (downloadUrl != null && downloadDir != null) { - DownloadUtils.downLoad( - context, downloadUrl, downloadDir, downloadVideoName, downListener - ) - } - } - - fun startPlay(localVideoPath: String?) { - if (localVideoPath === "") return - try { - Logger.d(ImageAndVideoRotation.TAG, "startPlay") - gsyVideoOptionBuilder = GSYVideoOptionBuilder() - gsyVideoOptionBuilder -// ?.setUrl("file:///mnt/sdcard/downloads/$downloadVideoName") - ?.setUrl(localVideoPath) // "/data/user/0/com.mogo.launcher.f/files/video/" - ?.setPlayTag(downloadVideoName) - ?.setCacheWithPlay(false) - ?.setThumbPlay(false) - ?.build(videoViewPlayer) - - videoViewPlayer?.isFocusableInTouchMode = false - videoViewPlayer?.setVideoAllCallBack(mOnCompletionListener) - videoViewPlayer?.startPlayLogic() - } catch (e: Exception) { - Logger.d(ImageAndVideoRotation.TAG, "startPlay e = ${e.message}") - } - } - - fun onVideoReset() { - videoViewPlayer?.onVideoReset() - mOnCompletionListener = null - } - - fun setPause() { - if (videoViewPlayer !== null) { - videoViewPlayer?.onVideoPause() - } - } - - fun setResume() { - if (videoViewPlayer !== null) { - videoViewPlayer?.onVideoResume() - } - } - - private val downListener = object : IDownloadListener { - override fun onStart(url: String) { - setCacheImageViewVisible() - Logger.d(ImageAndVideoRotation.TAG, "download-onStart") - } - -// override fun onPause(url: String, threadBean: ThreadBean?) { -// Logger.d(ImageAndVideoRotation.TAG, "download-onPause") -//// UiThreadHandler.postDelayed(Runnable { -//// startDownLoadVideo() -//// },DOWNLOAD_DELAY) -// // todo 测试下网络断掉是否会走onpause,且网络回复也不会继续下载 -// } - - override fun onProgress(url: String, downloaded: Long, total: Long) { - Logger.d(ImageAndVideoRotation.TAG, "download-onProgress== ${ (downloaded * 1.0f * 100/total).toInt() }") - } - - override fun onFinished(url: String, path: String) { - Logger.d(ImageAndVideoRotation.TAG, "download-onFinished = $url") - if (url.equals(fileNetPath)) { //发现下载工具在断网又连网后,已完成的任务又都下载,跳转播放出现问题 - //下载完成 - ThreadUtils.runOnUiThread { - startPlay(Uri.fromFile(File(path)).toString()) - } - } else {//如果当前文件不存在再次去下载当前的 - Logger.d( - ImageAndVideoRotation.TAG, "download-onFinished = not current" + - ",currentUrl = $fileNetPath " - ) - if (FileUtils.isFileExists(path)) { - Logger.d(ImageAndVideoRotation.TAG, "have download startPlay") - ThreadUtils.runOnUiThread { - startPlay(Uri.fromFile(File(path)).toString()) - } - return - } else { - startDownLoadVideo() - } - } - } - - override fun onError(url: String, error: String?) { - Logger.d(ImageAndVideoRotation.TAG, "download-onError-$error") - //出错再次下载 - startDownLoadVideo() - } - } -} \ No newline at end of file diff --git a/OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/ui/widget/video/AdvanceViewPager.kt b/OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/ui/widget/video/AdvanceViewPager.kt deleted file mode 100644 index 7bcb5ac291..0000000000 --- a/OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/ui/widget/video/AdvanceViewPager.kt +++ /dev/null @@ -1,24 +0,0 @@ -package com.mogo.och.bus.passenger.passenger.ui.widget.video - -import android.content.Context -import android.util.AttributeSet -import android.view.MotionEvent -import androidx.viewpager.widget.ViewPager - -/** - * @author: wangmingjun - * @date: 2023/2/21 - */ -class AdvanceViewPager: ViewPager{ - - constructor(context: Context) : super(context) - constructor(context: Context,attrs: AttributeSet?) : super(context,attrs) - - override fun onTouchEvent(ev: MotionEvent?): Boolean { - return false - } - - override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean { - return false - } -} \ No newline at end of file diff --git a/OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/ui/widget/video/ImageAndVideoRotation.kt b/OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/ui/widget/video/ImageAndVideoRotation.kt deleted file mode 100644 index 651b840c14..0000000000 --- a/OCH/bus/passenger/src/main/java/m2/com/mogo/och/bus/passenger/passenger/ui/widget/video/ImageAndVideoRotation.kt +++ /dev/null @@ -1,50 +0,0 @@ -package com.mogo.och.bus.passenger.passenger.ui.widget.video - -import android.annotation.SuppressLint -import android.content.Context -import android.util.AttributeSet -import android.widget.RelativeLayout -import com.mogo.och.bus.passenger.passenger.ui.widget.video.AdvancePagerAdapter -import com.mogo.och.bus.passenger.passenger.ui.widget.video.AdvanceViewPager -import com.mogo.och.common.module.wigets.video.RotationItem - -/** - * @author: wangmingjun - * @date: 2023/2/6 - */ -class ImageAndVideoRotation @JvmOverloads constructor( - context: Context, attrs: AttributeSet? = null -) : RelativeLayout(context, attrs) { - - private var viewPager: AdvanceViewPager? = null - private var pagerAdapter: AdvancePagerAdapter? = null - - companion object { - const val TAG = "ImageAndVideoRotation" - } - - init { - initView() - } - - @SuppressLint("ClickableViewAccessibility") - private fun initView() { - viewPager = AdvanceViewPager(context) - pagerAdapter = AdvancePagerAdapter(context, viewPager!!) - viewPager?.adapter = pagerAdapter - - addView(viewPager, LayoutParams(-1, -1)) - } - - fun setData(list: MutableList){ - pagerAdapter?.setData(list) - } - - fun setPause(){ - pagerAdapter?.setPause() - } - - fun setResume(){ - pagerAdapter?.setResume() - } -} \ No newline at end of file diff --git a/OCH/bus/passenger/src/main/res/m2/layout/bus_p_m2_video_fragment.xml b/OCH/bus/passenger/src/main/res/m2/layout/bus_p_m2_video_fragment.xml deleted file mode 100644 index 66e95d9087..0000000000 --- a/OCH/bus/passenger/src/main/res/m2/layout/bus_p_m2_video_fragment.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/OCH/bus/passenger/src/main/res/m2/layout/bus_p_m2_video_view.xml b/OCH/bus/passenger/src/main/res/m2/layout/bus_p_m2_video_view.xml deleted file mode 100644 index 9d75478ee1..0000000000 --- a/OCH/bus/passenger/src/main/res/m2/layout/bus_p_m2_video_view.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - \ No newline at end of file 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..c65bb403e7 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 @@ -22,6 +22,7 @@ import com.mogo.och.common.module.wigets.toast.ToastCharterUtils import com.mogo.eagle.core.widget.media.video.TextureVideoViewOutlineProvider import com.mogo.och.charter.passenger.R import com.mogo.och.charter.passenger.utils.FullVideoUtils +import com.mogo.och.common.module.wigets.media.MediaItem import com.shuyu.gsyvideoplayer.listener.VideoAllCallBack import com.shuyu.gsyvideoplayer.utils.GSYVideoType import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer @@ -51,6 +52,7 @@ class ConsultVideoPlayer : StandardGSYVideoPlayer { var smalllPlayer: ConsultVideoPlayer?=null private var currentTime = 0 + private var fileType = 0 constructor(context: Context?) : super(context) constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) @@ -125,7 +127,7 @@ class ConsultVideoPlayer : StandardGSYVideoPlayer { }else { start.setImageResource(R.drawable.charter_p_function_video_player_pause_small) } - aivStartPlay.visibility = View.GONE + showOrHideStartPlayButton(false) } else -> { if(isIfCurrentIsFullscreen){ @@ -133,7 +135,7 @@ class ConsultVideoPlayer : StandardGSYVideoPlayer { }else { start.setImageResource(R.drawable.charter_p_function_video_player_start_small) } - aivStartPlay.visibility = View.VISIBLE + showOrHideStartPlayButton(true) } } } @@ -490,5 +492,17 @@ class ConsultVideoPlayer : StandardGSYVideoPlayer { fun getVideoAllCallBack(): VideoAllCallBack? { return mVideoAllCallBack } + + fun setFileType(type: Int) { + this.fileType = type + } + + fun showOrHideStartPlayButton(isShow: Boolean) { + if (fileType == MediaItem.MEDIA_TYPE_IMAGE) { + aivStartPlay?.visibility = View.GONE + return + } + 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..0b4a79420f 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,26 @@ 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.mogo.och.common.module.wigets.media.MediaPlayLogger import com.shuyu.gsyvideoplayer.video.base.GSYVideoView import kotlinx.android.synthetic.main.charter_p_video_fragment.view.rvVideoPlaylist import kotlin.math.floor @@ -22,27 +36,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) { //播放视频 @@ -62,6 +81,7 @@ class VideoView @JvmOverloads constructor( } } prePlayerPosition = centerItemPosition + MediaPlayLogger.printInfoLog("pageSelect, currentPosition=$prePlayerPosition") } override fun pageStop() { @@ -70,7 +90,6 @@ class VideoView @JvmOverloads constructor( player.onVideoPause() } } - }) carouselLayoutManager.addOnDargAutoDiffListener { adapterPosition, currentPosition -> val fl = adapterPosition - floor(adapterPosition) @@ -84,16 +103,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 +123,43 @@ 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() + MediaPlayLogger.printInfoLog("onMediaDataSourceChanged:isNewData=$isNewData, dataSize=${list.size}, 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) + MediaPlayLogger.printInfoLog("onMediaDataSourceChanged, 宣传视频数据已更新") + } else { + mNewMediaList.clear() + mNewMediaList.addAll(localMediaList) + } + } else { + updateMediaListDataAndView(localMediaList) + MediaPlayLogger.printInfoLog("onMediaDataSourceChanged, 宣传视频数据已更新") + } + } + }) + } + 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 +170,7 @@ class VideoView @JvmOverloads constructor( } override fun onDetachedFromWindow() { + MediaDataSourceManager.unInit(TAG) super.onDetachedFromWindow() } @@ -133,40 +189,17 @@ class VideoView @JvmOverloads constructor( player.onVideoReset() } } + try { + // 在播放完成的时机更新整体数据 + if (mNewMediaList.isNotEmpty()) { + updateMediaListDataAndView(mNewMediaList) + mNewMediaList.clear() + MediaPlayLogger.printInfoLog("onVisibilityChanged, 宣传视频数据已更新") + } + } 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..aaa5ec7e79 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,42 @@ 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/OCH/common/common/src/main/AndroidManifest.xml b/OCH/common/common/src/main/AndroidManifest.xml index 01f5dc90e8..ceb2e638c5 100644 --- a/OCH/common/common/src/main/AndroidManifest.xml +++ b/OCH/common/common/src/main/AndroidManifest.xml @@ -3,11 +3,10 @@ extensionPos ? NOT_FOUND : extensionPos; + } + + public static int indexOfLastSeparator(final String filename) { + if (filename == null) { + return NOT_FOUND; + } + final int lastUnixPos = filename.lastIndexOf(UNIX_NAME_SEPARATOR);//unix的/ + final int lastWindowsPos = filename.lastIndexOf(WINDOWS_NAME_SEPARATOR);// windows的\ + return Math.max(lastUnixPos, lastWindowsPos); + } + + public static void main(String[] args) { + String url = "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357834634/5.m4v"; + String[] fileName = url.split("/"); + String fileSuffix = getExtension(fileName[fileName.length - 1]); + System.out.println(fileSuffix); + } +} diff --git a/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/media/MediaBean.kt b/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/media/MediaBean.kt new file mode 100644 index 0000000000..fc74f766a6 --- /dev/null +++ b/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/media/MediaBean.kt @@ -0,0 +1,23 @@ +package com.mogo.och.common.module.wigets.media + +data class MediaDataList(val medias: MutableList) + +data class MediaItem( + var fileUrl: String, + var fileType: Int, + var coverImageUrl: String, + var title: String +) { + companion object { + const val MEDIA_TYPE_IMAGE = 1 + const val MEDIA_TYPE_VIDEO = 2 + } + + fun isImageType(): Boolean { + return this.fileType == MEDIA_TYPE_IMAGE + } + + fun isVideoType(): Boolean { + return this.fileType == MEDIA_TYPE_VIDEO + } +} diff --git a/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/media/MediaDataSourceManager.kt b/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/media/MediaDataSourceManager.kt new file mode 100644 index 0000000000..02c4b79ee9 --- /dev/null +++ b/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/media/MediaDataSourceManager.kt @@ -0,0 +1,278 @@ +package com.mogo.och.common.module.wigets.media + +import android.annotation.SuppressLint +import android.content.Context +import android.text.TextUtils +import com.google.gson.reflect.TypeToken +import com.mogo.commons.AbsMogoApplication +import com.mogo.commons.debug.DebugConfig +import com.mogo.eagle.core.data.BaseData +import com.mogo.eagle.core.data.config.FunctionBuildConfig +import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager +import com.mogo.eagle.core.network.MoGoRetrofitFactory +import com.mogo.eagle.core.utilcode.util.GsonUtils +import com.mogo.eagle.core.utilcode.util.NetworkUtils +import com.mogo.eagle.core.utilcode.util.UiThreadHandler +import com.mogo.och.common.module.biz.constant.OchCommonConst +import com.mogo.och.common.module.biz.network.OchCommonServiceCallback +import com.mogo.och.common.module.biz.network.OchCommonSubscribeImpl +import com.mogo.och.common.module.biz.network.interceptor.transformTry +import com.mogo.och.common.module.wigets.media.MediaItem.Companion.MEDIA_TYPE_IMAGE +import com.mogo.och.common.module.wigets.media.MediaItem.Companion.MEDIA_TYPE_VIDEO +import io.reactivex.Observable +import retrofit2.http.GET +import retrofit2.http.Headers +import retrofit2.http.Query +import java.util.concurrent.ConcurrentHashMap + +/** + * 广告视频数据源 管理类 + * 1.第一优先级:从管理后台拿对应车型的宣传视频 + * 如果无网络或无司机SN或请求异常 失败5次后,立马使用第二优先级本地数据播放 + * 失败尝试时间间隔:1秒 + * 2.第二优先级:使用本地数据播放 + * 3.请求管理后台数据成功后:间隔5分钟再次检查 + */ +object MediaDataSourceManager { + private val TAG = MediaDataSourceManager::class.java.simpleName + + private const val RETRY_MAX_COUNT = 5 + + private var mRetryCount = 0 + + private val mNetworkService: IMediaNetworkApi = + MoGoRetrofitFactory.getInstance(OchCommonConst.getEagleMisUrl()) + .create(IMediaNetworkApi::class.java) + + private var driverSnCache = "" + + private val driverSn: String + get() { + val serverToken = CallerTelematicManager.getServerToken() + if (serverToken != driverSnCache && serverToken.isNotEmpty()) { + driverSnCache = serverToken + } + return driverSnCache + } + + val context: Context + get() { + return AbsMogoApplication.getApp() + } + + private val mLastMediaDataSourceList = mutableListOf() + + private var mHasEverGetMediaDataFromMis = false + + private val mMediaDataSourceListenerMap: ConcurrentHashMap = + ConcurrentHashMap() + + private val getAdDataSourceLoopRunnable = Runnable { + startGetMediaDataSourceLoop() + } + + fun init(tag: String, dataSourceListener: IMediaDataSourceListener) { + if (!mMediaDataSourceListenerMap.containsKey(tag)) { + mMediaDataSourceListenerMap[tag] = dataSourceListener + } + val isSassProject = isSassProject() + MediaPlayLogger.printInfoLog("init, 初始化环境 isSassProject=$isSassProject") + if (isSassProject) { + MediaPlayLogger.printInfoLog("init, 开始检查后台配置数据") + startGetMediaDataSourceLoop() + } else { + MediaPlayLogger.printInfoLog("init, 使用本地配置数据初始化") + //非Sass环境下后端没有实现可配置,默认只走本地配置 + val localAdDataList = getMediaDataFromLocalConfig() + updateMediaDataSource(localAdDataList) + } + } + + fun unInit(tag: String) { + MediaPlayLogger.printInfoLog("unInit") + removeGetMediaDataSourceLoop() + if (mMediaDataSourceListenerMap.containsKey(tag)) { + mMediaDataSourceListenerMap.remove(tag) + } + } + + /** + * 是否是Sass环境 + */ + private fun isSassProject(): Boolean { + return DebugConfig.getProjectFlavor().lowercase().contains("saas") + } + + @SuppressLint("MissingPermission") + private fun startGetMediaDataSourceLoop() { + MediaPlayLogger.printInfoLog("startGetMediaDataSourceLoop, 开始执行后台配置数据检查") + removeGetMediaDataSourceLoop() + // 失败5次,且从来没有从MIS获取配置信息成功过,先试用本地数据播放 + if (mRetryCount == RETRY_MAX_COUNT && !mHasEverGetMediaDataFromMis) { + val localAdDataList = getMediaDataFromLocalConfig() + updateMediaDataSource(localAdDataList) + MediaPlayLogger.printErrorLog("startGetMediaDataSourceLoop:失败${mRetryCount}次,先使用本地数据播放") + } + if (driverSn.isBlank()) { + MediaPlayLogger.printErrorLog("startGetMediaDataSourceLoop:司机屏sn为空,跳过本次查询") + mRetryCount++ + UiThreadHandler.postDelayed(getAdDataSourceLoopRunnable, 1000L) + return + } + if (!NetworkUtils.isConnected()) { + MediaPlayLogger.printErrorLog("startGetMediaDataSourceLoop:当前无网络,跳过本次查询") + mRetryCount++ + UiThreadHandler.postDelayed(getAdDataSourceLoopRunnable, 1000L) + return + } + getMediaDataFromMis(object : OchCommonServiceCallback { + override fun onSuccess(data: MediaDataResp?) { + mHasEverGetMediaDataFromMis = true + MediaPlayLogger.printInfoLog( + "startGetMediaDataSourceLoop:success, 从管理后台获取到数据,MediaSize=${data?.data?.size}, MediaData=${ + GsonUtils.toJson( + data + ) + }" + ) + val newDataList = MediaDataResp.toMediaItemList(data?.data) + // 管理平台如果配置数据为空,不更新 + if (newDataList.isNotEmpty()) { + if (compareMediaDataSource(newDataList)) { + updateMediaDataSource(newDataList) + MediaPlayLogger.printInfoLog("startGetMediaDataSourceLoop:success, 从管理后台获取到数据,数据有变化更新数据") + } else { + MediaPlayLogger.printInfoLog("startGetMediaDataSourceLoop:success, 从管理后台获取到数据,数据无变化无需更新") + } + } else { + //请求成功获取到后台配置数据了,但是数据为空,此时为了有内容展示,还是使用本地数据更新播放 + if (mLastMediaDataSourceList.isEmpty()) { + val localAdDataList = getMediaDataFromLocalConfig() + updateMediaDataSource(localAdDataList) + MediaPlayLogger.printInfoLog("startGetMediaDataSourceLoop:success, 从管理后台获取到数据,返回数据为空,使用本地配置数据播放") + } + } + + // 获取成功后,延迟5分钟再查询 + UiThreadHandler.postDelayed(getAdDataSourceLoopRunnable, 5 * 60 * 1000L) + MediaPlayLogger.printInfoLog("startGetMediaDataSourceLoop:success, 延迟5分钟后再次检查更新") + } + + override fun onFail(code: Int, msg: String?) { + MediaPlayLogger.printErrorLog("startGetMediaDataSourceLoop:failed, code=$code, msg=$msg") + mRetryCount++ + val delay = if (mHasEverGetMediaDataFromMis) 5000L else 1000L + UiThreadHandler.postDelayed(getAdDataSourceLoopRunnable, delay) + MediaPlayLogger.printErrorLog("startGetMediaDataSourceLoop:failed, 延迟${delay / 1000L}秒后再次请求") + } + + override fun onError() { + super.onError() + MediaPlayLogger.printErrorLog("startGetMediaDataSourceLoop:error, 网络异常") + mRetryCount++ + val delay = if (mHasEverGetMediaDataFromMis) 5000L else 1000L + UiThreadHandler.postDelayed(getAdDataSourceLoopRunnable, delay) + MediaPlayLogger.printErrorLog("startGetMediaDataSourceLoop:error, 网络异常,延迟${delay / 1000L}秒后再次请求") + } + }) + } + + private fun removeGetMediaDataSourceLoop() { + UiThreadHandler.removeCallbacks(getAdDataSourceLoopRunnable) + } + + private fun getMediaDataFromMis(callback: OchCommonServiceCallback) { + MediaPlayLogger.printInfoLog("getMediaDataFromMis:准备发送请求,driverSn=$driverSn") + mNetworkService.queryMediaDataFromMis( + sn = driverSn, + screenType = "2", + ).transformTry().subscribe(OchCommonSubscribeImpl(context, callback, "getMediaDataFromMis")) + } + + private fun getMediaDataFromLocalConfig(): List { + val localAdDataList = mutableListOf() + try { + val datas: MediaDataList = GsonUtils.fromJson( + FunctionBuildConfig.mediaUrlConfig, object : TypeToken() {}.type + ) + localAdDataList.addAll(datas.medias) + } catch (e: Exception) { + e.printStackTrace() + } + MediaPlayLogger.printInfoLog("getMediaDataFromLocalConfig, 获取本地配置数据,dataSize=${localAdDataList.size}") + return localAdDataList + } + + private fun compareMediaDataSource(newDataList: List): Boolean { + if (mLastMediaDataSourceList.isEmpty() && newDataList.isNotEmpty()) { + return true + } + if (mLastMediaDataSourceList.size != newDataList.size) { + return true + } + try { + newDataList.forEachIndexed { index, rotationItem -> + val oldIndexItem = mLastMediaDataSourceList[index] + if (rotationItem?.fileUrl != oldIndexItem?.fileUrl) { + return true + } + } + } catch (e: Exception) { + e.printStackTrace() + } + return false + } + + private fun updateMediaDataSource(newDataList: List) { + mLastMediaDataSourceList.clear() + mLastMediaDataSourceList.addAll(newDataList) + mMediaDataSourceListenerMap.forEach { + val listener = it.value + listener.onMediaDataSourceChanged(newDataList) + } + MediaPlayLogger.printInfoLog("下发新MediaData给监听者,dataSize=${newDataList.size}") + } + +} + +interface IMediaDataSourceListener { + fun onMediaDataSourceChanged(list: List) +} + +interface IMediaNetworkApi { + @Headers("Content-type:application/json;charset=UTF-8") + @GET("/platform/biz/adv/screen/advs") + fun queryMediaDataFromMis( + @Query("sn") sn: String, + @Query("screenType") screenType: String + ): Observable +} + +data class MediaData( + var id: String?, + var title: String?, //素材标题 + var brand: String?, + var file_type: Int = 0, //素材类型: 1 - 视频,2 - 图片 + var cover_path: String?, //封面图片, 适用 素材类型为视频 + var file_path: String?, //素材url + var descr: String?, //素材描述 + var apply_screen: Int = 0 //应用屏幕类型: 1司机屏幕 2乘客屏 +) + +data class MediaDataResp(val data: List) : BaseData() { + companion object { + fun toMediaItemList(mediaDataList: List?): List { + val rotationItemList = mutableListOf() + mediaDataList?.forEach { + val rotationItem = MediaItem( + fileUrl = if (TextUtils.isEmpty(it.file_path)) "" else "${it.file_path}", + fileType = if (it.file_type == 1) MEDIA_TYPE_VIDEO else MEDIA_TYPE_IMAGE, + coverImageUrl = if (TextUtils.isEmpty(it.cover_path)) "" else "${it.cover_path}", + title = if (TextUtils.isEmpty(it.title)) "" else "${it.title}" + ) + rotationItemList.add(rotationItem) + } + return rotationItemList + } + } +} diff --git a/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/media/MediaFileCacheManager.kt b/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/media/MediaFileCacheManager.kt new file mode 100644 index 0000000000..259e1daaae --- /dev/null +++ b/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/media/MediaFileCacheManager.kt @@ -0,0 +1,88 @@ +package com.mogo.och.common.module.wigets.media + +import android.content.Context +import android.os.Environment +import android.text.TextUtils +import android.util.Log +import com.mogo.eagle.core.utilcode.download.DownloadUtils +import com.mogo.eagle.core.utilcode.download.callback.IDownloadListener +import com.mogo.eagle.core.utilcode.util.EncryptUtils +import com.mogo.och.common.module.utils.FileUtils +import java.io.File + +/** + * 宣传视频文件本地缓存管理类 + * 1, 统一了本地缓存文件的存放目录 + * 2,统一了本地缓存文件的命名,md5编码 + */ +object MediaFileCacheManager { + + const val TAG = "MediaFileCacheManager" + + /** + * 创建media缓存文件夹目录(优先放SD卡) + */ + fun createFileCacheDir(context: Context): Boolean { + val cacheDirPath = getFileCacheDir(context) + MediaPlayLogger.printInfoLog("createFileCacheDir, dirPath=$cacheDirPath") + return com.mogo.eagle.core.utilcode.util.FileUtils.createFileDir(cacheDirPath) + } + + /** + * 获取本地缓存文件的文件全路径 + */ + private fun getFileCacheDir(context: Context): String { + // 有些手机需要通过自定义目录 + val relativePath = "mogo" + File.separator + "media" + File.separator + val cacheDir = File(Environment.getExternalStorageDirectory(), relativePath) + if (com.mogo.eagle.core.utilcode.util.FileUtils.createOrExistsDir(cacheDir)) { + return cacheDir.absolutePath + } + + return FileUtils.getCacheDirectory(context, "") + relativePath + } + + /** + * 本地缓存文件的文件名,md5编码避免文件名重复或者特殊字符编码问题 + */ + fun getCacheFileName(mediaUrl: String): String { + val fileSuffix = FileUtils.getExtension(mediaUrl) + if (TextUtils.isEmpty(fileSuffix)) { + Log.e(TAG, "getCacheFileName 根据url获取文件后缀不合法,mediaUrl=$mediaUrl") + return "" + } + return EncryptUtils.encryptMD5ToString(mediaUrl) + FileUtils.EXTENSION_SEPARATOR + fileSuffix + } + + /** + * 获取文件缓存的缓存path, 文件名以base64编码避免 中文命名,重复文件名的影响 + */ + fun getCacheFileFullPathByUrl(context: Context, mediaUrl: String): String { + return getFileCacheDir(context) + getCacheFileName(mediaUrl) + } + + /** + * 本地是否已经存在下载完成的文件 + */ + fun isLocalCacheFileExists(context: Context, mediaUrl: String): Boolean { + val localVideoCacheFilePath = + getCacheFileFullPathByUrl(context, mediaUrl) + return com.mogo.eagle.core.utilcode.util.FileUtils.isFileExists(localVideoCacheFilePath) + } + + /** + * 下载文件 + */ + fun downloadFile(context: Context, mediaUrl: String, listener: IDownloadListener) { + val downloadUrl = mediaUrl + val downloadDir = getFileCacheDir(context) + val downloadFileName = getCacheFileName(mediaUrl) + DownloadUtils.downLoad( + context, + downloadUrl, + downloadDir, + downloadFileName, + listener + ) + } +} \ No newline at end of file diff --git a/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/media/MediaLoopPlayView.kt b/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/media/MediaLoopPlayView.kt new file mode 100644 index 0000000000..af68e0398b --- /dev/null +++ b/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/media/MediaLoopPlayView.kt @@ -0,0 +1,311 @@ +package com.mogo.och.common.module.wigets.media + +import AdvanceImageView +import AdvanceVideoView +import android.content.Context +import android.util.AttributeSet +import android.view.MotionEvent +import android.view.View +import android.view.ViewGroup +import android.widget.RelativeLayout +import androidx.viewpager.widget.PagerAdapter +import androidx.viewpager.widget.ViewPager +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.util.CountDownTimer +import com.mogo.eagle.core.utilcode.util.ToastUtils +import com.mogo.och.common.module.wigets.media.MediaLoopPlayView.Companion.IMAGE_COUNT_DOWN_SECONDS +import com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack + +class MediaLoopPlayView @JvmOverloads constructor( + context: Context, attrs: AttributeSet? = null +) : RelativeLayout(context, attrs) { + + companion object { + const val TAG = "MediaLoopPlayView" + const val IMAGE_COUNT_DOWN_SECONDS = 5 + } + + private var viewPager: AdvanceViewPager? = null + private var pagerAdapter: AdvancePagerAdapter? = null + + init { + initView() + } + + private fun initView() { + viewPager = AdvanceViewPager(context) + pagerAdapter = AdvancePagerAdapter(context, viewPager!!) + viewPager?.adapter = pagerAdapter + addView(viewPager, LayoutParams(-1, -1)) + } + + fun setMediaData(list: MutableList) { + pagerAdapter?.setMediaData(list) + } + + fun setNewMediaData(list: MutableList) { + pagerAdapter?.setNewMediaData(list) + } + + fun setPause() { + pagerAdapter?.setPause() + } + + fun setResume() { + pagerAdapter?.setResume() + } +} + +class AdvanceViewPager : ViewPager { + constructor(context: Context) : super(context) + constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) + + override fun onTouchEvent(ev: MotionEvent?): Boolean { + return false + } + + override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean { + return false + } +} + +class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter(), + ViewPager.OnPageChangeListener { + + private val mContext: Context = context + private val mViewPager: ViewPager = viewPager + + private var mDataList = mutableListOf() + private var mItemViewList = mutableListOf() + + //新的数据,在轮播下一次切换的时机完成整体数据的更新 + private val mNewDataList: MutableList = mutableListOf() + + private var mLastViewPagerPosition = -1 + private var mImageCountDownTimer: CountDownTimer? = null + + fun setMediaData(list: MutableList) { + if (list.isEmpty()) { + MediaPlayLogger.printInfoLog( "setMediaData, list为空") + return + } + + mDataList.clear() + mDataList.addAll(list) + mItemViewList.clear() + list.forEach { + addItemView(it) + } + + mViewPager.addOnPageChangeListener(this) + notifyDataSetChanged() + mViewPager.currentItem = 0 + + if (mItemViewList.size > 0) { + startLoopPlay() + } + } + + fun setNewMediaData(list: MutableList) { + mNewDataList.clear() + mNewDataList.addAll(list) + } + + override fun getCount(): Int { + return mDataList.size + } + + override fun isViewFromObject(view: View, `object`: Any): Boolean { + return view === `object` + } + + override fun destroyItem(container: ViewGroup, position: Int, obj: Any) { + try { + container.removeView(obj as View) + } catch (e: Exception) { + e.printStackTrace() + } + } + + override fun instantiateItem(container: ViewGroup, position: Int): Any { + val view: View = mItemViewList[position] + container.addView(view) + return view + } + + override fun getItemPosition(`object`: Any): Int { + return POSITION_NONE + } + + private fun addItemView(item: MediaItem) { + if (item.isImageType()) { + val imageView = AdvanceImageView(mContext) + imageView.initImageUrlData(item.fileUrl) + mItemViewList.add(imageView) + } else if (item.isVideoType()) { + val videoView = AdvanceVideoView(mContext) + videoView.initVideoUrlData(item.fileUrl, item.coverImageUrl) + mItemViewList.add(videoView) + } else { + MediaPlayLogger.printErrorLog( "addItemView 不支持的文件类型:${item.fileType}") + } + } + + /** + * 开始播放循环 + * 1.如果是视频,开始播放视频,等到播放完成后根据media类型开始播放下一个 + * 2.如果是图片,展示图片,同时开始timer倒计时,倒计时完时根据media类型开始播放下一个 + */ + private fun startLoopPlay() { + val currentPosition = mViewPager.currentItem + val currentMediaItem = mDataList[currentPosition] + if (mItemViewList[currentPosition] is AdvanceVideoView) { + MediaPlayLogger.printInfoLog("startLoopPlay: AdvanceVideoView, url=${currentMediaItem.fileUrl}") + val videoView = mItemViewList[currentPosition] as AdvanceVideoView + videoView.setThumbImageViewVisible() + videoView.startPlayVideo(videoPlayLifecycleCallBack) + } else if (mItemViewList[currentPosition] is AdvanceImageView) { + MediaPlayLogger.printInfoLog("startLoopPlay: AdvanceImageView, url=${currentMediaItem.fileUrl}") + val imageView = mItemViewList[currentPosition] as AdvanceImageView + imageView.displayImage() + startImageCountDownTimer() + } else { + MediaPlayLogger.printErrorLog("startLoopPlay 不支持的文件类型:${currentMediaItem.fileType}, url=${currentMediaItem.fileUrl}") + } + } + + private var videoPlayLifecycleCallBack = object : GSYSampleCallBack() { + + override fun onPrepared(url: String?, vararg objects: Any?) { + CallerLogger.d(MediaLoopPlayView.TAG, "onPrepared") + } + + override fun onAutoComplete(url: String?, vararg objects: Any?) { + CallerLogger.d(MediaLoopPlayView.TAG, "onAutoComplete") + playNextItemView(false) + } + + override fun onPlayError(url: String?, vararg objects: Any?) { + super.onPlayError(url, *objects) + CallerLogger.d(MediaLoopPlayView.TAG, "onPlayError, error=${objects}") + playNextItemView(true) + } + } + + private fun startImageCountDownTimer() { + if (mImageCountDownTimer != null) { + mImageCountDownTimer?.cancel() + mImageCountDownTimer = null + } + mImageCountDownTimer = object : CountDownTimer(IMAGE_COUNT_DOWN_SECONDS * 1000L, 1000L) { + override fun onTick(millisUntilFinished: Long) { + CallerLogger.d( + MediaLoopPlayView.TAG, + "mImageCountDownTimer倒计时秒, countDown=${millisUntilFinished / 1000}" + ) + } + + override fun onFinish() { + MediaPlayLogger.printInfoLog( "mImageCountDownTimer, 倒计时${IMAGE_COUNT_DOWN_SECONDS}秒, onFinish") + playNextItemView(false) + } + }.start() + MediaPlayLogger.printInfoLog("mImageCountDownTimer, 开始倒计时 ${IMAGE_COUNT_DOWN_SECONDS}秒") + } + + private fun cancelImageCountDownTimer() { + if (mImageCountDownTimer != null) { + mImageCountDownTimer?.cancel() + mImageCountDownTimer = null + } + } + + /** + * 根据当前item情况,播放下一个item + */ + private fun playNextItemView(isOnVideoError: Boolean) { + // 在播放完成的时机更新整体数据 + if (mNewDataList.isNotEmpty()) { + setMediaData(mNewDataList) + mNewDataList.clear() + ToastUtils.showShort("宣传视频数据已更新") + MediaPlayLogger.printInfoLog("playNextItemView, 宣传视频数据已更新") + return + } + MediaPlayLogger.printInfoLog("playNextItemView") + + val currentPosition = mViewPager.currentItem + val currentMediaItem = mDataList[currentPosition] + val currentItemView = mItemViewList[currentPosition] + MediaPlayLogger.printInfoLog("playNextItemView, currentPosition=$currentPosition, type=${currentMediaItem.fileType}, url=${currentMediaItem.fileUrl}") + if (currentItemView is AdvanceVideoView) { + currentItemView.onVideoReset() + //videoView.setCacheImageViewVisible() + if (isOnVideoError) { + currentItemView.clearLocalErrorVideo() + } + if (mItemViewList.size == 1) { + currentItemView.startPlay(currentMediaItem.fileUrl) + return + } + } + if (currentPosition == mItemViewList.size - 1) { + //已经到最后一个, 从头开始 + mViewPager.post { + mViewPager.setCurrentItem(0, true) + } + } else { + mViewPager.post { + mViewPager.setCurrentItem(mViewPager.currentItem + 1, true) + } + } + } + + fun setPause() { + MediaPlayLogger.printInfoLog("${MediaLoopPlayView.TAG}, setPause") + if (mItemViewList.size <= 0) { + return + } + val currentPosition = mViewPager.currentItem + if (mItemViewList[currentPosition] is AdvanceVideoView) { + val videoView = mItemViewList[mViewPager.currentItem] as AdvanceVideoView + videoView.setVideoPause() + } else if (mItemViewList[currentPosition] is AdvanceImageView) { + cancelImageCountDownTimer() + } + } + + fun setResume() { + MediaPlayLogger.printInfoLog("${MediaLoopPlayView.TAG}, setResume") + if (mItemViewList.size <= 0) { + return + } + val currentPosition = mViewPager.currentItem + if (mItemViewList[currentPosition] is AdvanceVideoView) { + val videoView = mItemViewList[mViewPager.currentItem] as AdvanceVideoView + videoView.setVideoResume() + } else if (mItemViewList[currentPosition] is AdvanceImageView) { + startImageCountDownTimer() + } + } + + override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) { + } + + override fun onPageSelected(position: Int) { + } + + override fun onPageScrollStateChanged(state: Int) { + if (state == 0) { //静止,什么都没做 + val currentPosition = mViewPager.currentItem + CallerLogger.d( + MediaLoopPlayView.TAG, + "onPageScrollStateChanged, state = $state, currentItem = $currentPosition, lastPosition = $mLastViewPagerPosition" + ) + if (mItemViewList.size > 1) { //多于1,才会循环跳转 + startLoopPlay() + mLastViewPagerPosition = currentPosition + } + } + } +} \ No newline at end of file diff --git a/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayLogger.kt b/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayLogger.kt new file mode 100644 index 0000000000..2fdb2c88c9 --- /dev/null +++ b/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayLogger.kt @@ -0,0 +1,44 @@ +package com.mogo.och.common.module.wigets.media + +import androidx.lifecycle.ProcessLifecycleOwner +import androidx.lifecycle.lifecycleScope +import com.mogo.commons.utils.MogoAnalyticUtils +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch + +object MediaPlayLogger { + const val TAG = "MediaPlayLogger" + private const val MEDIA_PLAY_PROCESS_KEY_NODE_LOG = + "och.media.play.process.key.node.log" + + fun printInfoLog(msg: String) { + CallerLogger.i(TAG, msg) + trackEvent("Info", msg) + } + + fun printWarnLog(msg: String) { + CallerLogger.w(TAG, msg) + trackEvent("Warn", msg) + } + + fun printErrorLog(msg: String) { + CallerLogger.e(TAG, msg) + trackEvent("Error", msg) + } + + /** + * 上报埋点 + */ + private fun trackEvent(level: String, msg: String) { + ProcessLifecycleOwner.get().lifecycleScope.launch(Dispatchers.IO) { + val map: MutableMap = HashMap() + map["level"] = level + map["msg"] = msg + MogoAnalyticUtils.track( + MEDIA_PLAY_PROCESS_KEY_NODE_LOG, + map + ) + } + } +} \ No newline at end of file diff --git a/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerActivity.kt b/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayerActivity.kt similarity index 78% rename from OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerActivity.kt rename to OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayerActivity.kt index ee855ae81c..11e0ab9edb 100644 --- a/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerActivity.kt +++ b/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayerActivity.kt @@ -1,16 +1,16 @@ -package com.mogo.och.common.module.wigets.video +package com.mogo.och.common.module.wigets.media import android.os.Bundle import androidx.appcompat.app.AppCompatActivity import com.mogo.eagle.core.utilcode.util.BarUtils import com.mogo.och.common.module.R -class VideoPlayerActivity : AppCompatActivity() { +class MediaPlayerActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_video_player) - val fragment = VideoPlayerFragment() + val fragment = MediaPlayerFragment() supportFragmentManager.beginTransaction().add(R.id.videoPlayerContainer, fragment) .commitAllowingStateLoss() BarUtils.hideStatusBarAndSticky(this.window) diff --git a/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayerCustomView.kt b/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayerCustomView.kt new file mode 100644 index 0000000000..247966aac8 --- /dev/null +++ b/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayerCustomView.kt @@ -0,0 +1,380 @@ +import android.content.Context +import android.media.AudioManager +import android.net.Uri +import android.util.AttributeSet +import android.widget.ImageView +import android.widget.RelativeLayout +import com.bumptech.glide.Glide +import com.bumptech.glide.request.RequestOptions +import com.mogo.eagle.core.utilcode.download.callback.IDownloadListener +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.mogo.logger.Logger +import com.mogo.eagle.core.utilcode.util.FileUtils +import com.mogo.eagle.core.utilcode.util.ThreadUtils +import com.mogo.eagle.core.utilcode.util.UiThreadHandler +import com.mogo.eagle.core.widget.media.video.TextureVideoViewOutlineProvider +import com.mogo.och.common.module.R +import com.mogo.och.common.module.wigets.media.MediaFileCacheManager +import com.mogo.och.common.module.wigets.media.MediaLoopPlayView +import com.mogo.och.common.module.wigets.media.MediaPlayLogger +import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder +import com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack +import com.shuyu.gsyvideoplayer.utils.GSYVideoType +import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer +import me.jessyan.autosize.utils.AutoSizeUtils +import java.io.File + +class AdvanceVideoView @JvmOverloads constructor( + context: Context, attrs: AttributeSet? = null +) : RelativeLayout(context, attrs) { + + private var containerLayout: RelativeLayout? = null + private var thumbnailImageView: ImageView? = null + private var videoPlayerView: AdvanceGSYVideoPlayer? = null + + private var gsyVideoPlayerOptionBuilder: GSYVideoOptionBuilder? = null + private var gsyVideoPlayerLifecycleCallback: GSYSampleCallBack? = null + + private var thumbnailImageUrl: String = "" + private var videoUrl: String = "" + + private val downListener = object : IDownloadListener { + override fun onStart(url: String) { + setThumbImageViewVisible() + Logger.d(MediaLoopPlayView.TAG, "video play download, onStart") + } + + override fun onProgress(url: String, downloaded: Long, total: Long) { + val percent = (downloaded * 100 / total).toInt() + Logger.d( + MediaLoopPlayView.TAG, + "video play download, onProgress= ${percent}" + ) + if (percent % 10 == 0) { + MediaPlayLogger.printInfoLog("downListener,percent=$percent, downloadUrl=${videoUrl}") + } + } + + override fun onFinished(url: String, path: String) { + Logger.d(MediaLoopPlayView.TAG, "video play download, onFinished = $url") + //发现下载工具在断网又连网后,已完成的任务又都下载,跳转播放出现问题 + if (url == videoUrl) { + //下载完成 + ThreadUtils.runOnUiThread { + startPlay(Uri.fromFile(File(path)).toString()) + } + MediaPlayLogger.printInfoLog("download finished, 开始播放,downloadUrl=${videoUrl}") + } else {//如果当前文件不存在再次去下载当前的 + Logger.d( + MediaLoopPlayView.TAG, + "video play download, onFinished but not current url , currentUrl = $videoUrl" + ) + if (FileUtils.isFileExists(path)) { + Logger.d(MediaLoopPlayView.TAG, "video play download, had download, startPlay") + ThreadUtils.runOnUiThread { + startPlay(Uri.fromFile(File(path)).toString()) + } + MediaPlayLogger.printInfoLog("download finished, 开始播放,downloadUrl=${videoUrl}") + } else { + startDownLoadVideoFile() + } + } + } + + override fun onError(url: String, error: String?) { + Logger.d(MediaLoopPlayView.TAG, "video play download, onError msg=$error") + MediaPlayLogger.printErrorLog("download error, 准备重新下载,downloadUrl=${videoUrl}") + //出错再次下载 + startDownLoadVideoFile() + } + } + + init { + initView() + } + + private fun initView() { + //容器 + containerLayout = RelativeLayout(context) + addView(containerLayout, LayoutParams(-1, -1)) + + //缩略图 + thumbnailImageView = ImageView(context) + thumbnailImageView?.scaleType = ImageView.ScaleType.FIT_XY + + //视频播放控件 + if (videoPlayerView === null) { + videoPlayerView = AdvanceGSYVideoPlayer(context) + } + val videoPlayerViewLayoutParams = LayoutParams(-1, -1) + //设置videoview占满父view播放 + videoPlayerViewLayoutParams.addRule(ALIGN_PARENT_LEFT) + videoPlayerViewLayoutParams.addRule(ALIGN_PARENT_RIGHT) + videoPlayerViewLayoutParams.addRule(ALIGN_PARENT_TOP) + videoPlayerViewLayoutParams.addRule(ALIGN_PARENT_BOTTOM) + + containerLayout?.addView(videoPlayerView, videoPlayerViewLayoutParams) + } + + /** + * 初始化数据 + */ + fun initVideoUrlData(videoUrl: String, thumbnailImageUrl: String) { + // https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357834634/5.m4v + // https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360274126/10.mp4 + this.videoUrl = videoUrl + this.thumbnailImageUrl = thumbnailImageUrl + } + + /** + * 开始播放逻辑 + */ + fun startPlayVideo(onCompletionListener: GSYSampleCallBack) { + //首先根据url检查video是否有已经下载完的本地视频文件 + gsyVideoPlayerLifecycleCallback = onCompletionListener + if (MediaFileCacheManager.isLocalCacheFileExists(context, this.videoUrl)) { + val localVideoCacheFilePath = MediaFileCacheManager.getCacheFileFullPathByUrl( + context, this.videoUrl + ) + MediaPlayLogger.printInfoLog("本地已经有缓存文件,准备开始播放,videoPath=${localVideoCacheFilePath}") + val realUri = Uri.fromFile(File(localVideoCacheFilePath)).toString() + setThumbImageViewGone() + startPlay(realUri) + CallerLogger.d( + MediaLoopPlayView.TAG, "播放视频,videoUri=$realUri" + ) + } else { + thumbnailImageView?.setImageResource(R.drawable.video_holder) + videoPlayerView?.thumbImageView = thumbnailImageView + thumbnailImageView?.also { + Glide.with(context).asBitmap().load(thumbnailImageUrl) + .apply( + RequestOptions().useUnlimitedSourceGeneratorsPool(true) + .placeholder(R.drawable.video_holder) + .error(R.drawable.video_holder) + .fallback(R.drawable.video_holder) + .centerCrop() + ) + .into(it) + } + setThumbImageViewVisible() + + startDownLoadVideoFile() + MediaPlayLogger.printInfoLog("本地无缓存文件,准备下载,downloadUrl=${this.videoUrl}") + } + } + + fun setThumbImageViewVisible() { + UiThreadHandler.post { + videoPlayerView?.setCacheImageViewVisible() + } + } + + private fun setThumbImageViewGone() { + UiThreadHandler.post { + videoPlayerView?.setCacheImageViewGone() + } + } + + private fun startDownLoadVideoFile() { + //下载视频,下载成功后再播放 + MediaPlayLogger.printInfoLog( "startDownLoadVideoFile, downloadUrl=${this.videoUrl}") + MediaFileCacheManager.downloadFile( + context, + videoUrl, + downListener + ) + } + + fun clearLocalErrorVideo() { + val localVideoPath = MediaFileCacheManager.getCacheFileFullPathByUrl(context, videoUrl) + if (FileUtils.isFileExists(localVideoPath)) { + FileUtils.delete(localVideoPath) + } + MediaPlayLogger.printInfoLog( "clearLocalErrorVideo, localPath=${localVideoPath}") + } + + fun startPlay(localVideoPath: String?) { + try { + Logger.d(MediaLoopPlayView.TAG, "startPlay") + gsyVideoPlayerOptionBuilder = GSYVideoOptionBuilder() + gsyVideoPlayerOptionBuilder + ?.setUrl(localVideoPath) // "/data/user/0/com.mogo.launcher.f/files/video/" + ?.setPlayTag(MediaFileCacheManager.getCacheFileName(videoUrl)) + ?.setCacheWithPlay(false) + ?.setThumbPlay(false) + ?.build(videoPlayerView) + + videoPlayerView?.isFocusableInTouchMode = false + videoPlayerView?.setVideoAllCallBack(gsyVideoPlayerLifecycleCallback) + videoPlayerView?.startPlayLogic() + } catch (e: Exception) { + Logger.e(MediaLoopPlayView.TAG, "startPlay error, msg=${e.message}") + } + } + + fun onVideoReset() { + videoPlayerView?.onVideoReset() + gsyVideoPlayerLifecycleCallback = null + } + + fun setVideoPause() { + videoPlayerView?.onVideoPause() + } + + fun setVideoResume() { + videoPlayerView?.onVideoResume() + } +} + +class AdvanceGSYVideoPlayer : StandardGSYVideoPlayer { + constructor(context: Context?) : super(context) + constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) + + init { + hideWidget() + GSYVideoType.setShowType(GSYVideoType.SCREEN_MATCH_FULL) + GSYVideoType.setRenderType(GSYVideoType.GLSURFACE) + } + + override fun hideAllWidget() { + Logger.d(MediaLoopPlayView.TAG, "AdvanceGSYVideoPlayer,hideAllWidget") + } + + override fun changeUiToNormal() { + Logger.d(MediaLoopPlayView.TAG, "AdvanceGSYVideoPlayer,changeUiToNormal-hide") + hideWidget() + } + + override fun changeUiToPreparingShow() { + Logger.d(MediaLoopPlayView.TAG, "AdvanceGSYVideoPlayer,changeUiToPreparingShow-hide") + hideWidget() + } + + override fun changeUiToPlayingShow() { + Logger.d(MediaLoopPlayView.TAG, "AdvanceGSYVideoPlayer,changeUiToPlayingShow") + setCacheImageViewGone() + } + + override fun changeUiToPauseShow() { + Logger.d(MediaLoopPlayView.TAG, "AdvanceGSYVideoPlayer,changeUiToPauseShow-hide") + startPlayLogic() + } + + override fun changeUiToCompleteShow() { + Logger.d(MediaLoopPlayView.TAG, "AdvanceGSYVideoPlayer,changeUiToCompleteShow") + setCacheImageViewGone() + } + + override fun changeUiToPlayingBufferingShow() { + Logger.d(MediaLoopPlayView.TAG, "AdvanceGSYVideoPlayer,changeUiToPlayingBufferingShow") + hideWidget() + } + + override fun changeUiToError() { + Logger.d(MediaLoopPlayView.TAG, "AdvanceGSYVideoPlayer,changeUiToError") + hideWidget() + } + + private fun hideWidget() { + setViewShowState(mBottomContainer, INVISIBLE) + setViewShowState(mProgressBar, INVISIBLE) + setViewShowState(mCurrentTimeTextView, INVISIBLE) + setViewShowState(mTotalTimeTextView, INVISIBLE) + setViewShowState(mBottomProgressBar, INVISIBLE) + setViewShowState(mBackButton, INVISIBLE) + setViewShowState(mStartButton, INVISIBLE) + + setViewShowState(mThumbImageViewLayout, VISIBLE) + setViewShowState(mThumbImageView, VISIBLE) + + setViewShowState(mTopContainer, INVISIBLE) + setViewShowState(mLoadingProgressBar, INVISIBLE) + setViewShowState(mLockScreen, INVISIBLE) + + setIsTouchWiget(false) + isFocusableInTouchMode = false + } + + fun setCacheImageViewVisible() { + Logger.d(MediaLoopPlayView.TAG, "AdvanceGSYVideoPlayer,setCacheImageViewVisible") + setViewShowState(mThumbImageViewLayout, VISIBLE) +// setViewShowState(mThumbImageView, VISIBLE) + } + + fun setCacheImageViewGone() { + Logger.d(MediaLoopPlayView.TAG, "AdvanceGSYVideoPlayer,setCacheImageViewGone") + setViewShowState(mThumbImageViewLayout, INVISIBLE) +// setViewShowState(mThumbImageView, INVISIBLE) + } + + //失去焦点声音压低 + override fun onLossTransientCanDuck() { +// setStreamVolume(0.2f) + setNeedMute(true) + } + + //获取焦点声音恢复 + override fun onGankAudio() { +// setStreamVolume(5.0f) + setNeedMute(false) + } + + private fun setStreamVolume(percent: Float) { + var mAudioManager = mContext?.getSystemService(Context.AUDIO_SERVICE) as AudioManager + var maxVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC) + var volume = (percent * maxVolume).toInt() + if (volume < 0) { + volume = 0 + } + mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, volume, 0) + } + + private fun setNeedMute(isMute: Boolean) { + gsyVideoManager?.player?.setNeedMute(isMute) + } + + override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { + super.onSizeChanged(w, h, oldw, oldh) + if (!mIfCurrentIsFullscreen) { + val dp2px = AutoSizeUtils.dp2px(context, 16f) + this.outlineProvider = TextureVideoViewOutlineProvider(dp2px.toFloat()) + this.clipToOutline = true + } + } +} + +class AdvanceImageView @JvmOverloads constructor( + context: Context, attrs: AttributeSet? = null +) : RelativeLayout(context, attrs) { + + private var imageView: ImageView? = null + private var imageUrl: String = "" + + init { + initView() + } + + private fun initView() { + imageView = ImageView(context) + imageView?.scaleType = ImageView.ScaleType.FIT_XY + addView(imageView, LayoutParams(-1, -1)) + } + + fun initImageUrlData(url: String) { + this.imageUrl = url + } + + fun displayImage() { + imageView?.setImageResource(R.drawable.video_holder) + imageView?.also { + Glide.with(context).asBitmap().load(imageUrl).apply( + RequestOptions().useUnlimitedSourceGeneratorsPool(true) + .placeholder(R.drawable.video_holder) + .error(R.drawable.video_holder) + .fallback(R.drawable.video_holder) + .centerCrop() + ).into(it) + } + } +} \ No newline at end of file diff --git a/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayerFragment.kt b/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayerFragment.kt new file mode 100644 index 0000000000..e6b8e3fd7a --- /dev/null +++ b/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayerFragment.kt @@ -0,0 +1,75 @@ +package com.mogo.och.common.module.wigets.media + +import com.mogo.commons.mvp.MvpFragment +import com.mogo.commons.mvp.Presenter +import com.mogo.eagle.core.function.main.MainMoGoApplication +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.common.module.R +import kotlinx.android.synthetic.main.fragment_video_player.imageVideoRotationView + +/** + * @author: wangmingjun + * @date: 2022/4/12 + */ +class MediaPlayerFragment : + MvpFragment() { + + companion object { + private val TAG = MediaPlayerFragment::class.java.simpleName + } + + private var arrayListOf = mutableListOf() + + override fun getLayoutId(): Int { + return R.layout.fragment_video_player + } + + override fun createPresenter(): MediaPlayerPresenter { + return MediaPlayerPresenter(this) + } + + override fun getTagName(): String { + return TAG + } + + override fun initViews() { + MediaFileCacheManager.createFileCacheDir(MainMoGoApplication.getApp().applicationContext) + MediaDataSourceManager.init(TAG, object : IMediaDataSourceListener { + override fun onMediaDataSourceChanged(list: List) { + val isNewData = arrayListOf.isNotEmpty() + CallerLogger.d( + TAG, "onMediaDataSourceChanged:isNewData=$isNewData, list=${GsonUtils.toJson(list)}" + ) + arrayListOf.clear() + arrayListOf.addAll(list) + UiThreadHandler.post { + if (isNewData) { + imageVideoRotationView.setNewMediaData(arrayListOf) + } else { + imageVideoRotationView.setMediaData(arrayListOf) + } + } + } + }) + } + + override fun onPause() { + super.onPause() + imageVideoRotationView.setPause() + } + + override fun onResume() { + super.onResume() + imageVideoRotationView.setResume() + } + + override fun onDestroy() { + MediaDataSourceManager.unInit(TAG) + super.onDestroy() + } +} + +class MediaPlayerPresenter(view: MediaPlayerFragment?) : + Presenter(view) \ No newline at end of file diff --git a/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/video/AdsDatas.kt b/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/video/AdsDatas.kt deleted file mode 100644 index 777f13a502..0000000000 --- a/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/video/AdsDatas.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.mogo.och.common.module.wigets.video - -data class AdsDatas(val ads:MutableList) - -data class RotationItem( - var path: String, - var type: Int, - var cacheImgPath: String, - var title: String -) diff --git a/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/video/ImageVideoRotationView.kt b/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/video/ImageVideoRotationView.kt deleted file mode 100644 index cdf8741b67..0000000000 --- a/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/video/ImageVideoRotationView.kt +++ /dev/null @@ -1,44 +0,0 @@ -package com.mogo.och.common.module.wigets.video - -import AdvancePagerAdapter -import AdvanceViewPager -import android.annotation.SuppressLint -import android.content.Context -import android.util.AttributeSet -import android.widget.RelativeLayout - -class ImageVideoRotationView @JvmOverloads constructor( - context: Context, attrs: AttributeSet? = null -) : RelativeLayout(context, attrs) { - - private var viewPager: AdvanceViewPager? = null - private var pagerAdapter: AdvancePagerAdapter? = null - - companion object { - const val TAG = "ImageAndVideoRotation" - } - - init { - initView() - } - - @SuppressLint("ClickableViewAccessibility") - private fun initView() { - viewPager = AdvanceViewPager(context) - pagerAdapter = AdvancePagerAdapter(context, viewPager!!) - viewPager?.adapter = pagerAdapter - addView(viewPager, LayoutParams(-1, -1)) - } - - fun setData(list: MutableList) { - pagerAdapter?.setData(list) - } - - fun setPause() { - pagerAdapter?.setPause() - } - - fun setResume() { - pagerAdapter?.setResume() - } -} \ No newline at end of file diff --git a/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerFragment.kt b/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerFragment.kt deleted file mode 100644 index 1e1a3cbd17..0000000000 --- a/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerFragment.kt +++ /dev/null @@ -1,62 +0,0 @@ -package com.mogo.och.common.module.wigets.video - -import com.google.gson.reflect.TypeToken -import com.mogo.commons.mvp.MvpFragment -import com.mogo.commons.mvp.Presenter -import com.mogo.eagle.core.data.config.FunctionBuildConfig -import com.mogo.eagle.core.utilcode.util.GsonUtils -import com.mogo.och.common.module.R -import kotlinx.android.synthetic.main.fragment_video_player.* - -/** - * @author: wangmingjun - * @date: 2022/4/12 - */ -class VideoPlayerFragment : - MvpFragment() { - - private var arrayListOf = mutableListOf() - - override fun getLayoutId(): Int { - return R.layout.fragment_video_player - } - - override fun createPresenter(): VideoPlayerPresenter { - return VideoPlayerPresenter(this) - } - - companion object { - private val TAG = VideoPlayerFragment::class.java.simpleName - } - - override fun getTagName(): String { - return TAG - } - - override fun initViews() { - initResourceData() - imageVideoRotationView.setData(arrayListOf) - } - - override fun onPause() { - super.onPause() - imageVideoRotationView.setPause() - } - - override fun onResume() { - super.onResume() - imageVideoRotationView.setResume() - } - - private fun initResourceData() { - try { - arrayListOf.clear() - var datas: AdsDatas = GsonUtils.fromJson(FunctionBuildConfig.tempConfig,object : TypeToken() {}.type) - arrayListOf.addAll(datas.ads) - } catch (e: Exception) { - } - } -} - -class VideoPlayerPresenter(view: VideoPlayerFragment?) : - Presenter(view) \ No newline at end of file diff --git a/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerView.kt b/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerView.kt deleted file mode 100644 index b61739f75b..0000000000 --- a/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerView.kt +++ /dev/null @@ -1,589 +0,0 @@ -import android.annotation.SuppressLint -import android.content.Context -import android.media.AudioManager -import android.net.Uri -import android.util.AttributeSet -import android.view.MotionEvent -import android.view.View -import android.view.ViewGroup -import android.widget.ImageView -import android.widget.RelativeLayout -import androidx.viewpager.widget.PagerAdapter -import androidx.viewpager.widget.ViewPager -import com.bumptech.glide.Glide -import com.bumptech.glide.request.RequestOptions -import com.mogo.eagle.core.utilcode.download.* -import com.mogo.eagle.core.utilcode.download.callback.* -import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger -import com.mogo.eagle.core.utilcode.mogo.logger.Logger -import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant -import com.mogo.eagle.core.utilcode.util.CountDownTimer -import com.mogo.eagle.core.utilcode.util.FileUtils -import com.mogo.eagle.core.utilcode.util.ThreadUtils -import com.mogo.eagle.core.utilcode.util.UiThreadHandler -import com.mogo.och.common.module.R -import com.mogo.och.common.module.wigets.video.ImageVideoRotationView -import com.mogo.och.common.module.wigets.video.RotationItem -import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder -import com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack -import com.shuyu.gsyvideoplayer.utils.Debuger -import com.shuyu.gsyvideoplayer.utils.GSYVideoType -import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer -import java.io.File - -class AdvanceVideoView @JvmOverloads constructor( - context: Context, attrs: AttributeSet? = null -) : RelativeLayout(context, attrs) { - - private var videoRelativeLayout: RelativeLayout? = null - private var cacheImage: ImageView? = null - private var videoViewPlayer: AdvanceGSYVideoPlayer? = null - private var gsyVideoOptionBuilder: GSYVideoOptionBuilder? = null - private var mOnCompletionListener: GSYSampleCallBack? = null - private var downloadVideoName = "" - private var fileNetPath: String? = "" - private var cacheImageUrl: String? = "" - private var mVideoDirPath: String? = "" - - init { - mVideoDirPath = context.filesDir.absolutePath + File.separator + "video" + File.separator - initView() - } - - private fun initView() { - initCacheImgView() - initVideoView() - } - - private fun initCacheImgView() { - cacheImage = ImageView(context) - cacheImage?.scaleType = ImageView.ScaleType.FIT_XY - } - - private fun initVideoView() { - videoRelativeLayout = RelativeLayout(context) - addView(videoRelativeLayout, LayoutParams(-1, -1)) - - if (videoViewPlayer === null) { - //视频播放控件 - videoViewPlayer = AdvanceGSYVideoPlayer(context) - } - - var layoutParams = LayoutParams(-1, -1) - //设置videoview占满父view播放 - layoutParams.addRule(ALIGN_PARENT_LEFT) - layoutParams.addRule(ALIGN_PARENT_RIGHT) - layoutParams.addRule(ALIGN_PARENT_TOP) - layoutParams.addRule(ALIGN_PARENT_BOTTOM) - - videoRelativeLayout?.addView(videoViewPlayer, layoutParams) - } - - fun setVideoPath(path: String, cacheImageUrl: String) { - // https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357834634/5.m4v - // https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360274126/10.mp4 - this.fileNetPath = path - this.cacheImageUrl = cacheImageUrl - val pathList = path.split("/") - if (pathList.isNotEmpty()) { - this.downloadVideoName = pathList[pathList.size - 1] - } - } - - private fun loadCacheImg() { - videoViewPlayer?.thumbImageView = cacheImage - cacheImage?.setImageResource(R.drawable.video_holder) -// setCacheImageViewVisible() - Logger.d(ImageVideoRotationView.TAG, "setVideoPath") - cacheImage?.let { - Glide.with(context).asBitmap().load(cacheImageUrl) - .apply( - RequestOptions().useUnlimitedSourceGeneratorsPool(true) - .placeholder(R.drawable.video_holder) - .error(R.drawable.video_holder) - .fallback(R.drawable.video_holder) - .centerCrop() - ) - .into(it) - } - } - - fun clearLocalErrorVideo() { - if (downloadVideoName.isNotEmpty() - && FileUtils.isFileExists(mVideoDirPath + downloadVideoName) - ) { - FileUtils.delete(mVideoDirPath + downloadVideoName) - } - } - - @SuppressLint("CheckResult") - fun setCacheImageViewVisible() { - UiThreadHandler.post { - videoViewPlayer?.setCacheImageViewVisible() - } - } - - fun setCacheImageViewGone() { - UiThreadHandler.post { - videoViewPlayer?.setCacheImageViewGone() - } - } - - fun setVideo(onCompletionListener: GSYSampleCallBack) { - loadCacheImg() - Logger.d(ImageVideoRotationView.TAG, "setVideo") - mOnCompletionListener = onCompletionListener - //判断是否已经下载 - if (downloadVideoName.isNotEmpty()) { - Logger.d( - ImageVideoRotationView.TAG, - "video local url = $mVideoDirPath$downloadVideoName" - ) - if (FileUtils.isFileExists(mVideoDirPath + downloadVideoName)) { - Logger.d(ImageVideoRotationView.TAG, "have cache startPlay") - startPlay(Uri.fromFile(File(mVideoDirPath + downloadVideoName)).toString()) - return - } - startDownLoadVideo() - } - } - - private fun startDownLoadVideo() { - //下载视频, 下载成功后再播放 - Logger.d(ImageVideoRotationView.TAG, "startDownLoadVideo") - FileUtils.createFileDir(mVideoDirPath) - DownloadUtils.downLoad( - context, fileNetPath!!, mVideoDirPath!!, downloadVideoName, downListener) - } - - fun startPlay(localVideoPath: String?) { - try { - Logger.d(ImageVideoRotationView.TAG, "startPlay") - gsyVideoOptionBuilder = GSYVideoOptionBuilder() - gsyVideoOptionBuilder - ?.setUrl( - localVideoPath - ) // "/data/user/0/com.mogo.launcher.f/files/video/" - ?.setPlayTag(downloadVideoName) - ?.setCacheWithPlay(false) - ?.setThumbPlay(false) - ?.build(videoViewPlayer) - - videoViewPlayer?.isFocusableInTouchMode = false - videoViewPlayer?.setVideoAllCallBack(mOnCompletionListener) - videoViewPlayer?.startPlayLogic() - } catch (e: Exception) { - Logger.d(ImageVideoRotationView.TAG, "startPlay e = ${e.message}") - } - } - - fun onVideoReset() { - videoViewPlayer?.onVideoReset() - mOnCompletionListener = null - } - - fun setPause() { - if (videoViewPlayer !== null) { - videoViewPlayer?.onVideoPause() - } - } - - fun setResume() { - if (videoViewPlayer !== null) { - videoViewPlayer?.onVideoResume() - } - } - - private val downListener = object : IDownloadListener { - - override fun onStart(url: String) { - setCacheImageViewVisible() - Logger.d(ImageVideoRotationView.TAG, "download-onStart") - } - - override fun onProgress(url: String, downloaded: Long, total: Long) { - Logger.d(ImageVideoRotationView.TAG, "download-onProgress== ${ (downloaded * 100 / total).toInt() }") - } - - override fun onFinished(url: String, path: String) { - Logger.d(ImageVideoRotationView.TAG, "download-onFinished = $url") - if (url == fileNetPath) { //发现下载工具在断网又连网后,已完成的任务又都下载,跳转播放出现问题 - //下载完成 - ThreadUtils.runOnUiThread { - startPlay(Uri.fromFile(File(path)).toString()) - } - } else {//如果当前文件不存在再次去下载当前的 - Logger.d( - ImageVideoRotationView.TAG, "download-onFinished = not current" + - ",currentUrl = $fileNetPath " - ) - if (FileUtils.isFileExists(path)) { - Logger.d(ImageVideoRotationView.TAG, "have download startPlay") - ThreadUtils.runOnUiThread { - startPlay(Uri.fromFile(File(path)).toString()) - } - return - } else { - startDownLoadVideo() - } - } - } - - override fun onError(url: String, error: String?) { - Logger.d(ImageVideoRotationView.TAG, "download-onError-$error") - //出错再次下载 - startDownLoadVideo() - } - } -} - -class AdvanceViewPager : ViewPager { - constructor(context: Context) : super(context) - constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) - - override fun onTouchEvent(ev: MotionEvent?): Boolean { - return false - } - - override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean { - return false - } -} - -class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter(), - ViewPager.OnPageChangeListener { - private val mContext: Context = context - private val mViewPager: ViewPager = viewPager - - private var dataList = mutableListOf() - private var viewList = mutableListOf() - - private var lastPosition = -1 - - private var current = 0 - private val time = 5000 - private var pause = false - private var countDownTimer: CountDownTimer? = null - - fun setData(list: MutableList) { - if (list.isEmpty()) return - dataList.addAll(list) - viewList.clear() - list.forEach { - addView(it) - } - - mViewPager.addOnPageChangeListener(this) - notifyDataSetChanged() - mViewPager.currentItem = 0 - - if (viewList.size > 0) { - if (viewList[mViewPager.currentItem] is AdvanceVideoView) {//有人反应第一个是视频不播放这边优化了一下 - Logger.d(ImageVideoRotationView.TAG, "第一个是视频") - val video = viewList[mViewPager.currentItem] as AdvanceVideoView - video.setVideo(gsySampleCallBack) - } else if (viewList[mViewPager.currentItem] is AdvanceImageView) { - Logger.d(ImageVideoRotationView.TAG, "startTimer()_1") - current = 0//换页重新计算时间 - startTimer() - } - } - } - - override fun getCount(): Int { - return dataList.size - } - - override fun isViewFromObject(view: View, `object`: Any): Boolean { - return view === `object` - } - - override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) { - container.removeView(viewList[position]) - } - - override fun instantiateItem(container: ViewGroup, position: Int): Any { - val view: View = viewList[position] - container.addView(view) - return view - } - - override fun getItemPosition(`object`: Any): Int { - return POSITION_NONE - } - - private fun addView(item: RotationItem) { - if (item.type == 1) { // 表示视频 - val videoView = AdvanceVideoView(mContext) - videoView.setVideoPath(item.path, item.cacheImgPath) - viewList.add(videoView) - } else { // 表示图片 - val imageView = AdvanceImageView(mContext) - imageView.setImagePath(item.path) - viewList.add(imageView) - } - } - - fun setPause() { - pause = true - if (viewList.size > 0 && viewList[mViewPager.currentItem] is AdvanceVideoView) { - val videoView = viewList[mViewPager.currentItem] as AdvanceVideoView - videoView.setPause() - } - } - - fun setResume() { - pause = false - if (viewList.size > 0 && viewList[mViewPager.currentItem] is AdvanceVideoView) { - val videoView = viewList[mViewPager.currentItem] as AdvanceVideoView - videoView.setResume() - } - } - - override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) { - } - - override fun onPageSelected(position: Int) { - } - - override fun onPageScrollStateChanged(state: Int) { - // 由于viewpager的预加载机制onPageSelected这里面加载videoview 放的跟玩一样 等操作完成后再播放videoview就香了 很丝滑 - if (state == 0) { //静止,什么都没做 - val currentItem = mViewPager.currentItem - Logger.d( - ImageVideoRotationView.TAG, - "state = $state currentItem = $currentItem lastPosition = $lastPosition" - ) - if (viewList.size > 1) { //多于1,才会循环跳转 - if (viewList[mViewPager.currentItem] is AdvanceVideoView) { - val videoView = (viewList[mViewPager.currentItem] as AdvanceVideoView) - videoView.setCacheImageViewVisible() - videoView.setVideo(gsySampleCallBack) - } else if (viewList[mViewPager.currentItem] is AdvanceImageView) { - Logger.d(ImageVideoRotationView.TAG, "startTimer()") - current = 0//换页重新计算时间 - startTimer() - } - lastPosition = mViewPager.currentItem - } - } - } - - private var gsySampleCallBack = object : GSYSampleCallBack() { - - override fun onPrepared(url: String?, vararg objects: Any?) { - Logger.d(ImageVideoRotationView.TAG, "onPrepared") -// if (viewList[mViewPager.currentItem] is AdvanceVideoView) { -// val videoView = (viewList[mViewPager.currentItem] as AdvanceVideoView) -// UiThreadHandler.postDelayed(Runnable { -// videoView.setCacheImageViewGone() -// }, 1000) -// } - } - - override fun onAutoComplete(url: String?, vararg objects: Any?) { - Logger.d(ImageVideoRotationView.TAG, "onAutoComplete()") - if (viewList[mViewPager.currentItem] is AdvanceVideoView) { - val videoView = (viewList[mViewPager.currentItem] as AdvanceVideoView) - videoView.onVideoReset() - if (viewList.size == 1){ - videoView.startPlay(url) - }else{ - goNextItemView() - - } - } - } - - override fun onPlayError(url: String?, vararg objects: Any?) { - super.onPlayError(url, *objects) - Logger.d(ImageVideoRotationView.TAG, "onPlayError()-${objects}") - if (viewList[mViewPager.currentItem] is AdvanceVideoView) { - val videoView = (viewList[mViewPager.currentItem] as AdvanceVideoView) - videoView.onVideoReset() -// videoView.setCacheImageViewVisible() - videoView.clearLocalErrorVideo() - goNextItemView() - } - } - } - - private fun startTimer() { - if (countDownTimer != null) { - countDownTimer?.cancel() - countDownTimer = null - } - countDownTimer = object : CountDownTimer(5000, 1000) { - override fun onTick(millisUntilFinished: Long) { - CallerLogger.d( - SceneConstant.M_BUS_P + "startTimer", - "倒计时秒 = ${millisUntilFinished / 1000}" - ) - } - - override fun onFinish() { - CallerLogger.d(ImageVideoRotationView.TAG + "startTimer", "5s到,跳转") - goNextItemView() - } - }.start() - } - - /** - * view 跳转 - */ - private fun goNextItemView() { - if (mViewPager.currentItem == viewList.size - 1) {//已经到最后一个 - mViewPager.post { - mViewPager.setCurrentItem(0, true) - } - } else { - mViewPager.post { - mViewPager.setCurrentItem(mViewPager.currentItem + 1, true) - } - } - } -} - -class AdvanceImageView @JvmOverloads constructor( - context: Context, attrs: AttributeSet? = null -) : RelativeLayout(context, attrs) { - - private var imageView: ImageView? = null - - init { - initView() - } - - private fun initView() { - imageView = ImageView(context) - imageView?.scaleType = ImageView.ScaleType.FIT_XY - addView(imageView, LayoutParams(-1, -1)) - } - - @SuppressLint("CheckResult") - fun setImagePath(path: String) { - imageView?.setImageResource(R.drawable.video_holder) - imageView?.let { - Glide.with(context).asBitmap().load(path) - .apply( - RequestOptions().useUnlimitedSourceGeneratorsPool(true) - .placeholder(R.drawable.video_holder) - .error(R.drawable.video_holder) - .fallback(R.drawable.video_holder) - .centerCrop() - ) - .into(it) - } - } -} - -class AdvanceGSYVideoPlayer : StandardGSYVideoPlayer { - constructor(context: Context?) : super(context) - constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) - - init { - hideWidget() - GSYVideoType.setShowType(GSYVideoType.SCREEN_MATCH_FULL) - GSYVideoType.setRenderType(GSYVideoType.GLSURFACE) - } - - override fun hideAllWidget() { - Logger.d("ImageAndVideoRotation", "hideAllWidget") - } - - override fun changeUiToNormal() { - Logger.d("ImageAndVideoRotation", "changeUiToNormal-hide") - hideWidget() - } - - override fun changeUiToPreparingShow() { - Logger.d("ImageAndVideoRotation", "changeUiToPreparingShow-hide") - hideWidget() - } - - override fun changeUiToPlayingShow() { - Logger.d("ImageAndVideoRotation", "changeUiToPlayingShow") - setCacheImageViewGone() - } - - override fun changeUiToPauseShow() { - Logger.d("ImageAndVideoRotation", "changeUiToPauseShow-hide") - startPlayLogic() - } - - override fun changeUiToCompleteShow() { - Logger.d("ImageAndVideoRotation", "changeUiToCompleteShow") - setCacheImageViewGone() - } - - override fun changeUiToPlayingBufferingShow() { - Logger.d("ImageAndVideoRotation", "changeUiToPlayingBufferingShow -hide") - hideWidget() - } - - override fun changeUiToError() { - Logger.d("ImageAndVideoRotation", "changeUiToError-hide") - hideWidget() - } - - private fun hideWidget(){ - setViewShowState(mBottomContainer, INVISIBLE) - setViewShowState(mProgressBar, INVISIBLE) - setViewShowState(mCurrentTimeTextView, INVISIBLE) - setViewShowState(mTotalTimeTextView, INVISIBLE) - setViewShowState(mBottomProgressBar, INVISIBLE) - setViewShowState(mBackButton, INVISIBLE) - setViewShowState(mStartButton, INVISIBLE) - - setViewShowState(mThumbImageViewLayout, VISIBLE) - setViewShowState(mThumbImageView, VISIBLE) - - setViewShowState(mTopContainer, INVISIBLE) - - setViewShowState(mLoadingProgressBar, INVISIBLE) - setViewShowState( - mLockScreen, INVISIBLE - ) - - setIsTouchWiget(false) - isFocusableInTouchMode = false - } - - fun setCacheImageViewVisible() { - Logger.d("ImageAndVideoRotation", "CacheImageViewVISIBLE") - setViewShowState(mThumbImageViewLayout, VISIBLE) -// setViewShowState(mThumbImageView, VISIBLE) - } - - fun setCacheImageViewGone() { - Logger.d("ImageAndVideoRotation", "CacheImageViewGONE") - setViewShowState(mThumbImageViewLayout, INVISIBLE) -// setViewShowState(mThumbImageView, INVISIBLE) - } - - //失去焦点声音压低 - override fun onLossTransientCanDuck() { -// setStreamVolume(0.2f) - setNeedMute(true) - } - - //获取焦点声音恢复 - override fun onGankAudio() { -// setStreamVolume(5.0f) - setNeedMute(false) - } - - private fun setStreamVolume(percent: Float){ - var mAudioManager = mContext?.getSystemService(Context.AUDIO_SERVICE) as AudioManager - var maxVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC) - var volume = (percent * maxVolume).toInt() - if (volume < 0 ){ - volume = 0 - } - mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC,volume,0) - } - - private fun setNeedMute(isMute: Boolean){ - gsyVideoManager?.player?.setNeedMute(isMute) - } -} \ No newline at end of file diff --git a/OCH/common/common/src/main/res/layout/fragment_video_player.xml b/OCH/common/common/src/main/res/layout/fragment_video_player.xml index 44c0c0702f..8b12b3606c 100644 --- a/OCH/common/common/src/main/res/layout/fragment_video_player.xml +++ b/OCH/common/common/src/main/res/layout/fragment_video_player.xml @@ -2,11 +2,9 @@ - - - \ No newline at end of file diff --git a/OCH/shuttle/passenger/src/main/java/com/mogo/och/shuttle/passenger/MogoOCHShuttlePassenger.kt b/OCH/shuttle/passenger/src/main/java/com/mogo/och/shuttle/passenger/MogoOCHShuttlePassenger.kt index 9167b387ac..dbfbc2bd11 100644 --- a/OCH/shuttle/passenger/src/main/java/com/mogo/och/shuttle/passenger/MogoOCHShuttlePassenger.kt +++ b/OCH/shuttle/passenger/src/main/java/com/mogo/och/shuttle/passenger/MogoOCHShuttlePassenger.kt @@ -13,7 +13,7 @@ import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant import com.mogo.eagle.core.utilcode.util.MultiDisplayUtils import com.mogo.och.shuttle.passenger.constant.BusPassengerConst -import com.mogo.och.common.module.wigets.video.VideoPlayerActivity +import com.mogo.och.common.module.wigets.media.MediaPlayerActivity import com.mogo.och.shuttle.passenger.ui.BusPassengerRouteFragment import com.mogo.och.shuttle.passenger.ui.PM2BaseFragment @@ -34,7 +34,7 @@ class MogoOCHShuttlePassenger : IMoGoFunctionProvider { showFragment() if (AppIdentityModeUtils.isJL(FunctionBuildConfig.appIdentityMode)) { mActivity?.let { - MultiDisplayUtils.startActWithSecond(it, VideoPlayerActivity::class.java) + MultiDisplayUtils.startActWithSecond(it, MediaPlayerActivity::class.java) } } return null diff --git a/OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/presenter/PM2VideoPresenter.kt b/OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/presenter/PM2VideoPresenter.kt deleted file mode 100644 index 247a9ea7f1..0000000000 --- a/OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/presenter/PM2VideoPresenter.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.mogo.och.shuttle.passenger.presenter - -import com.mogo.commons.mvp.Presenter -import com.mogo.och.shuttle.passenger.ui.video.PM2VideoFragment - -class PM2VideoPresenter(view: PM2VideoFragment?) : - Presenter(view) \ No newline at end of file diff --git a/OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/ui/PM2BaseFragment.kt b/OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/ui/PM2BaseFragment.kt index c84ad52e02..ee2aa21d7f 100644 --- a/OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/ui/PM2BaseFragment.kt +++ b/OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/ui/PM2BaseFragment.kt @@ -3,7 +3,9 @@ package com.mogo.och.shuttle.passenger.ui import com.mogo.commons.mvp.MvpFragment import com.mogo.och.shuttle.passenger.R import com.mogo.och.shuttle.passenger.presenter.PM2Presenter -import com.mogo.och.shuttle.passenger.ui.video.PM2VideoFragment +import com.mogo.och.common.module.wigets.media.MediaPlayerActivity +import com.mogo.och.common.module.wigets.media.MediaPlayerFragment + /** * @author: wangmingjun @@ -14,7 +16,7 @@ class PM2BaseFragment : private var drivingFragment : PM2DrivingInfoFragment? = null private var hdMapFragment : PM2HPMapFragment? = null - private var videoFragment : PM2VideoFragment? = null + private var mediaFragment : MediaPlayerFragment? = null override fun getLayoutId(): Int { return R.layout.shuttle_p_m2_fragment @@ -55,9 +57,9 @@ class PM2BaseFragment : childFragmentManager.beginTransaction().add(R.id.hd_map_fragment, hdMapFragment!!) .show(hdMapFragment!!).commitAllowingStateLoss() - if (videoFragment == null) videoFragment = PM2VideoFragment() - childFragmentManager.beginTransaction().add(R.id.video_fragment, videoFragment!!) - .show(videoFragment!!).commitAllowingStateLoss() + if (mediaFragment == null) mediaFragment = MediaPlayerFragment() + childFragmentManager.beginTransaction().add(R.id.video_fragment, mediaFragment!!) + .show(mediaFragment!!).commitAllowingStateLoss() } override fun createPresenter(): PM2Presenter { diff --git a/OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/ui/video/PM2VideoFragment.kt b/OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/ui/video/PM2VideoFragment.kt deleted file mode 100644 index 9752b6b86a..0000000000 --- a/OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/ui/video/PM2VideoFragment.kt +++ /dev/null @@ -1,64 +0,0 @@ -package com.mogo.och.shuttle.passenger.ui.video - -import com.google.gson.reflect.TypeToken -import com.mogo.commons.mvp.MvpFragment -import com.mogo.eagle.core.data.config.FunctionBuildConfig -import com.mogo.eagle.core.utilcode.util.GsonUtils -import com.mogo.och.shuttle.passenger.R -import com.mogo.och.shuttle.passenger.presenter.PM2VideoPresenter -import com.mogo.och.common.module.wigets.video.AdsDatas -import com.mogo.och.common.module.wigets.video.RotationItem -import kotlinx.android.synthetic.main.shuttle_p_m2_video_fragment.imageVideoRotationView - -/** - * @author: wangmingjun - * @date: 2022/4/12 - */ -class PM2VideoFragment : - MvpFragment() { - - private var arrayListOf = mutableListOf() - - override fun getLayoutId(): Int { - return R.layout.shuttle_p_m2_video_fragment - } - - - override fun createPresenter(): PM2VideoPresenter { - return PM2VideoPresenter(this) - } - - companion object { - private val TAG = PM2VideoFragment::class.java.simpleName - } - - override fun getTagName(): String { - return TAG - } - - override fun initViews() { - initResourceData() - imageVideoRotationView.setData(arrayListOf) - } - - override fun onPause() { - super.onPause() - imageVideoRotationView.setPause() - } - - override fun onResume() { - super.onResume() - imageVideoRotationView.setResume() - } - - private fun initResourceData() { - - try { - arrayListOf.clear() - var datas: AdsDatas = GsonUtils.fromJson(FunctionBuildConfig.tempConfig,object : TypeToken() {}.type) - arrayListOf.addAll(datas.ads) - } catch (e: Exception) { - e.printStackTrace() - } - } -} \ No newline at end of file diff --git a/OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/ui/widget/video/AdvanceGSYVideoPlayer.kt b/OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/ui/widget/video/AdvanceGSYVideoPlayer.kt deleted file mode 100644 index 22b19e955f..0000000000 --- a/OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/ui/widget/video/AdvanceGSYVideoPlayer.kt +++ /dev/null @@ -1,137 +0,0 @@ -package com.mogo.och.shuttle.passenger.ui.widget.video - -import android.content.Context -import android.media.AudioManager -import android.util.AttributeSet -import com.mogo.eagle.core.utilcode.mogo.logger.Logger -import com.mogo.eagle.core.widget.media.video.TextureVideoViewOutlineProvider -import com.shuyu.gsyvideoplayer.utils.GSYVideoType -import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer -import me.jessyan.autosize.utils.AutoSizeUtils - -/** - * @author: wangmingjun - * @date: 2023/2/17 - * 隐藏所有控件的player - */ -class AdvanceGSYVideoPlayer: StandardGSYVideoPlayer { - constructor(context: Context?) : super(context) - constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) - - init { - hideWidget() - GSYVideoType.setShowType(GSYVideoType.SCREEN_TYPE_16_9) - GSYVideoType.setRenderType(GSYVideoType.GLSURFACE) - } - - override fun hideAllWidget() { - Logger.d(ImageAndVideoRotation.TAG, "hideAllWidget") -// hideWidget() - } - - override fun changeUiToNormal() { - Logger.d(ImageAndVideoRotation.TAG, "changeUiToNormal-hide") - hideWidget() - } - - override fun changeUiToPreparingShow() { - Logger.d(ImageAndVideoRotation.TAG, "changeUiToPreparingShow-hide") - hideWidget() - } - - override fun changeUiToPlayingShow() { - Logger.d(ImageAndVideoRotation.TAG, "changeUiToPlayingShow") - setCacheImageViewGone() - } - - override fun changeUiToPauseShow() { - Logger.d(ImageAndVideoRotation.TAG, "changeUiToPauseShow-hide") - startPlayLogic() -// hideWidget() - } - - override fun changeUiToCompleteShow() { - Logger.d(ImageAndVideoRotation.TAG, "changeUiToCompleteShow") - setCacheImageViewGone() - } - - override fun changeUiToPlayingBufferingShow() { - Logger.d(ImageAndVideoRotation.TAG, "changeUiToPlayingBufferingShow -hide") - hideWidget() - } - - override fun changeUiToError() { - Logger.d(ImageAndVideoRotation.TAG, "changeUiToError-hide") - hideWidget() - } - - private fun hideWidget(){ - setViewShowState(mBottomContainer, INVISIBLE) - setViewShowState(mProgressBar, INVISIBLE) - setViewShowState(mCurrentTimeTextView, INVISIBLE) - setViewShowState(mTotalTimeTextView, INVISIBLE) - setViewShowState(mBottomProgressBar, INVISIBLE) - setViewShowState(mBackButton, INVISIBLE) - setViewShowState(mStartButton, INVISIBLE) - - setViewShowState(mThumbImageViewLayout, VISIBLE) - setViewShowState(mThumbImageView, VISIBLE) - - setViewShowState(mTopContainer, INVISIBLE) - - setViewShowState(mLoadingProgressBar, INVISIBLE) - setViewShowState( - mLockScreen, INVISIBLE - ) - - setIsTouchWiget(false) - isFocusableInTouchMode = false - } - - fun setCacheImageViewVisible() { - Logger.d(ImageAndVideoRotation.TAG, "CacheImageViewVISIBLE") - setViewShowState(mThumbImageViewLayout, VISIBLE) -// setViewShowState(mThumbImageView, VISIBLE) - } - - fun setCacheImageViewGone() { - Logger.d(ImageAndVideoRotation.TAG, "CacheImageViewGONE") - setViewShowState(mThumbImageViewLayout, INVISIBLE) -// setViewShowState(mThumbImageView, INVISIBLE) - } - - //失去焦点声音压低 - override fun onLossTransientCanDuck() { -// setStreamVolume(0.2f) - setNeedMute(true) - } - - //获取焦点声音恢复 - override fun onGankAudio() { -// setStreamVolume(5.0f) - setNeedMute(false) - } - - private fun setStreamVolume(percent: Float){ - var mAudioManager = mContext?.getSystemService(Context.AUDIO_SERVICE) as AudioManager - var maxVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC) - var volume = (percent * maxVolume).toInt() - if (volume < 0 ){ - volume = 0 - } - mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC,volume,0) - } - - private fun setNeedMute(isMute: Boolean){ - gsyVideoManager?.player?.setNeedMute(isMute) - } - - override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { - super.onSizeChanged(w, h, oldw, oldh) - if (!mIfCurrentIsFullscreen) { - val dp2px = AutoSizeUtils.dp2px(context, 16f) - this.outlineProvider = TextureVideoViewOutlineProvider(dp2px.toFloat()) - this.clipToOutline = true - } - } -} \ No newline at end of file diff --git a/OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/ui/widget/video/AdvanceImageView.kt b/OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/ui/widget/video/AdvanceImageView.kt deleted file mode 100644 index 7967e593b7..0000000000 --- a/OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/ui/widget/video/AdvanceImageView.kt +++ /dev/null @@ -1,45 +0,0 @@ -package com.mogo.och.shuttle.passenger.ui.widget.video - -import android.annotation.SuppressLint -import android.content.Context -import android.util.AttributeSet -import android.widget.ImageView -import android.widget.RelativeLayout -import com.bumptech.glide.Glide -import com.bumptech.glide.request.RequestOptions -import com.mogo.och.shuttle.passenger.R - -/** - * @author: wangmingjun - * @date: 2023/2/6 - */ -class AdvanceImageView @JvmOverloads constructor( - context: Context, attrs: AttributeSet? = null -) : RelativeLayout(context, attrs) { - - private var imageView: ImageView? = null - - init { - initView() - } - - private fun initView() { - imageView = ImageView(context) - imageView?.scaleType = ImageView.ScaleType.FIT_XY - addView(imageView, LayoutParams(-1, -1)) - } - - @SuppressLint("CheckResult") - fun setImagePath(path: String){ - imageView?.setImageResource(R.drawable.shuttle_p_m2_p_video_holder) - imageView?.let { Glide.with(context).asBitmap().load(path) - .apply( - RequestOptions().useUnlimitedSourceGeneratorsPool(true) - .placeholder(R.drawable.shuttle_p_m2_p_video_holder) - .error(R.drawable.shuttle_p_m2_p_video_holder) - .fallback(R.drawable.shuttle_p_m2_p_video_holder) - .centerCrop() - ) - .into(it) } - } -} \ No newline at end of file diff --git a/OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/ui/widget/video/AdvancePagerAdapter.kt b/OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/ui/widget/video/AdvancePagerAdapter.kt deleted file mode 100644 index f5e47f2d6e..0000000000 --- a/OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/ui/widget/video/AdvancePagerAdapter.kt +++ /dev/null @@ -1,211 +0,0 @@ -package com.mogo.och.shuttle.passenger.ui.widget.video - -import android.content.Context -import android.view.View -import android.view.ViewGroup -import androidx.viewpager.widget.PagerAdapter -import androidx.viewpager.widget.ViewPager -import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d -import com.mogo.eagle.core.utilcode.mogo.logger.Logger -import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant -import com.mogo.eagle.core.utilcode.util.CountDownTimer -import com.mogo.och.common.module.wigets.video.RotationItem -import com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack - -/** - * @author: wangmingjun - * @date: 2023/2/6 - */ -class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter(), - ViewPager.OnPageChangeListener { - - private val mContext: Context = context - private val mViewPager: ViewPager = viewPager - - private var dataList = mutableListOf() - private var viewList = mutableListOf() - - private var lastPosition = -1 - - private var current = 0 - private val time = 5000 - private var pause = false - private var countDownTimer: CountDownTimer? = null - - fun setData(list: MutableList) { - if (list.isEmpty()) return - dataList.addAll(list) - - viewList.clear() - - list.forEach { - addView(it) - } - - mViewPager.addOnPageChangeListener(this) - - notifyDataSetChanged() - - mViewPager.currentItem = 0 - - if (viewList.size > 0) { - if (viewList[mViewPager.currentItem] is AdvanceVideoView) {//有人反应第一个是视频不播放这边优化了一下 - Logger.d(ImageAndVideoRotation.TAG, "第一个是视频") - val video = viewList[mViewPager.currentItem] as AdvanceVideoView - video.setVideo(gsySampleCallBack) - - } else if (viewList[mViewPager.currentItem] is AdvanceImageView) { - Logger.d(ImageAndVideoRotation.TAG, "startTimer()_1") - current = 0//换页重新计算时间 - startTimer() - } - } - } - - override fun getCount(): Int { - return dataList.size - } - - override fun isViewFromObject(view: View, `object`: Any): Boolean { - return view === `object` - } - - override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) { - container.removeView(viewList[position]) - } - - override fun instantiateItem(container: ViewGroup, position: Int): Any { - val view: View = viewList[position] - container.addView(view) - return view - - } - - override fun getItemPosition(`object`: Any): Int { - return POSITION_NONE - } - - private fun addView(item: RotationItem) { - if (item.type == 1) { // 表示视频 - val videoView = AdvanceVideoView(mContext) - videoView.setVideoPath(item.path,item.cacheImgPath) - viewList.add(videoView) - } else { // 表示图片 - val imageView = AdvanceImageView(mContext) - imageView.setImagePath(item.path) - viewList.add(imageView) - } - } - - fun setPause() { - pause = true - if (viewList.size > 0 && viewList[mViewPager.currentItem] is AdvanceVideoView) { - val videoView = viewList[mViewPager.currentItem] as AdvanceVideoView - videoView.setPause() - } - } - - fun setResume() { - pause = false - if (viewList.size > 0 && viewList[mViewPager.currentItem] is AdvanceVideoView) { - val videoView = viewList[mViewPager.currentItem] as AdvanceVideoView - videoView.setResume() - } - } - - override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) { - } - - override fun onPageSelected(position: Int) { - } - - override fun onPageScrollStateChanged(state: Int) { - // 由于viewpager的预加载机制onPageSelected这里面加载videoview 放的跟玩一样 等操作完成后再播放videoview就香了 很丝滑 - if (state == 0) { //静止,什么都没做 - val currentItem = mViewPager.currentItem - Logger.d(ImageAndVideoRotation.TAG, - "state = $state currentItem = $currentItem lastPosition = $lastPosition") - - if (viewList.size > 1) { //多于1,才会循环跳转 - - if (viewList[mViewPager.currentItem] is AdvanceVideoView) { - - val videoView = (viewList[mViewPager.currentItem] as AdvanceVideoView) - videoView.setCacheImageViewVisible() - videoView.setVideo(gsySampleCallBack) - - } else if (viewList[mViewPager.currentItem] is AdvanceImageView) { - Logger.d(ImageAndVideoRotation.TAG, "startTimer()") - current = 0//换页重新计算时间 - startTimer() - } - lastPosition = mViewPager.currentItem - } - } - } - - private var gsySampleCallBack = object : GSYSampleCallBack() { - - override fun onPrepared(url: String?, vararg objects: Any?) { - Logger.d(ImageAndVideoRotation.TAG, "onPrepared--$url") - } - - override fun onAutoComplete(url: String?, vararg objects: Any?) { - Logger.d(ImageAndVideoRotation.TAG, "onAutoComplete()-$url") - if (viewList[mViewPager.currentItem] is AdvanceVideoView){ - val videoView = (viewList[mViewPager.currentItem] as AdvanceVideoView) - if (viewList.size == 1){ - videoView.startPlay(url) - }else{ - videoView.onVideoReset() - goNextItemView() - } - } - } - - override fun onPlayError(url: String?, vararg objects: Any?) { - super.onPlayError(url, *objects) - Logger.d(ImageAndVideoRotation.TAG, "onPlayError()-$url") - if (viewList[mViewPager.currentItem] is AdvanceVideoView){ - val videoView = (viewList[mViewPager.currentItem] as AdvanceVideoView) - videoView.onVideoReset() -// videoView.setCacheImageViewVisible() - videoView.clearLocalErrorVideo() - goNextItemView() - } - } - } - - private fun startTimer() { - if (countDownTimer != null){ - countDownTimer?.cancel() - countDownTimer = null - } - countDownTimer = object : CountDownTimer(5000,1000){ - override fun onTick(millisUntilFinished: Long) { - d(SceneConstant.M_BUS_P + "startTimer", "倒计时秒 = ${millisUntilFinished/1000}" ) - } - - override fun onFinish() { - d(ImageAndVideoRotation.TAG+ "startTimer", "5s到,跳转") - goNextItemView() - } - - }.start() - } - - /** - * view 跳转 - */ - private fun goNextItemView() { - if (mViewPager.currentItem == viewList.size - 1) {//已经到最后一个 - mViewPager.post { - mViewPager.setCurrentItem(0, true) - } - } else { - mViewPager.post { - mViewPager.setCurrentItem(mViewPager.currentItem + 1, true) - } - } - } -} \ No newline at end of file diff --git a/OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/ui/widget/video/AdvanceVideoView.kt b/OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/ui/widget/video/AdvanceVideoView.kt deleted file mode 100644 index 18179b3065..0000000000 --- a/OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/ui/widget/video/AdvanceVideoView.kt +++ /dev/null @@ -1,254 +0,0 @@ -package com.mogo.och.shuttle.passenger.ui.widget.video - -import android.annotation.SuppressLint -import android.content.Context -import android.net.Uri -import android.util.AttributeSet -import android.widget.ImageView -import android.widget.RelativeLayout -import com.mogo.eagle.core.utilcode.download.* -import com.mogo.eagle.core.utilcode.download.callback.* -import com.mogo.eagle.core.utilcode.mogo.logger.Logger -import com.mogo.eagle.core.utilcode.util.FileUtils -import com.mogo.eagle.core.utilcode.util.ThreadUtils -import com.mogo.eagle.core.utilcode.util.UiThreadHandler -import com.mogo.och.shuttle.passenger.R -import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder -import com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack -import java.io.File - -/** - * @author: wangmingjun - * @date: 2023/2/8 - */ -class AdvanceVideoView @JvmOverloads constructor( - context: Context, attrs: AttributeSet? = null -) : RelativeLayout(context, attrs) { - - private var videoRelativeLayout: RelativeLayout? = null - private var cacheImage: ImageView? = null - - private var videoViewPlayer: AdvanceGSYVideoPlayer? = null - private var gsyVideoOptionBuilder: GSYVideoOptionBuilder? = null - private var mOnCompletionListener: GSYSampleCallBack? = null - private var downloadVideoName = "" - private var fileNetPath: String? = "" - private var cacheImageUrl: String? = "" - private var mVideoDirPath: String? = "" - - init { - mVideoDirPath = context.filesDir.absolutePath + File.separator + "video" + File.separator -// mVideoDirPath = Config.downLoadPath - initView() - } - - private fun initView() { - initVideoView() - initCacheImgView() - } - - private fun initCacheImgView() { - cacheImage = ImageView(context) - cacheImage?.scaleType = ImageView.ScaleType.FIT_XY -// addView(cacheImage, LayoutParams(-1, -1)) - } - - private fun initVideoView() { - videoRelativeLayout = RelativeLayout(context) - val outLayout = LayoutParams(-1, -1) - addView(videoRelativeLayout, outLayout) - - if (videoViewPlayer === null) { - //视频播放控件 - videoViewPlayer = AdvanceGSYVideoPlayer(context) - } - - val layoutParams = LayoutParams(-1, -1) - //设置videoview占满父view播放 - layoutParams.addRule(ALIGN_PARENT_LEFT) - layoutParams.addRule(ALIGN_PARENT_RIGHT) - layoutParams.addRule(ALIGN_PARENT_TOP) - layoutParams.addRule(ALIGN_PARENT_BOTTOM) - - videoRelativeLayout?.addView(videoViewPlayer, layoutParams) - } - - fun setVideoPath(path: String, cacheImageUrl: String) { - // https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357834634/5.m4v - // https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360274126/10.mp4 - this.fileNetPath = path - this.cacheImageUrl = cacheImageUrl - val pathList = path.split("/") - if (pathList.isNotEmpty()) { - this.downloadVideoName = pathList[pathList.size - 1] - } - } - - private fun loadCacheImg() { - // BitmapHelper.getVideoThumbnail(path) /*获取第一帧图* -// OCHThreadPoolManager.getsInstance().execute { -// var bitmap = BitmapHelper.getVideoThumbnail(fileNetPath) - Logger.d(ImageAndVideoRotation.TAG, "setVideoPath") -// ThreadUtils.runOnUiThread { -// Logger.d(ImageAndVideoRotation.TAG, "bitmap加载") - cacheImage?.setImageResource(R.drawable.shuttle_p_m2_p_video_holder) -// cacheImage?.let { //暂时去掉加载首帧图,加载视频时,用本地默认图 -// Glide.with(context).asBitmap().load(cacheImageUrl) -// .apply( -// RequestOptions().useUnlimitedSourceGeneratorsPool(true) -// .placeholder(R.drawable.m2_p_video_holder) -// .error(R.drawable.m2_p_video_holder) -// .fallback(R.drawable.m2_p_video_holder) -// .centerCrop() -// ) -// .into(it) -// } - videoViewPlayer?.thumbImageView = cacheImage -// setCacheImageViewVisible() -// } -// } - } - - fun clearLocalErrorVideo() { - if (downloadVideoName.isNotEmpty() - && FileUtils.isFileExists(mVideoDirPath + downloadVideoName) - ) { - FileUtils.delete(mVideoDirPath + downloadVideoName) - } - } - - @SuppressLint("CheckResult") - fun setCacheImageViewVisible() { - UiThreadHandler.post { -// cacheImage?.visibility = VISIBLE - videoViewPlayer?.setCacheImageViewVisible() - } - } - - fun setCacheImageViewGone() { - UiThreadHandler.post { -// cacheImage?.visibility = GONE - videoViewPlayer?.setCacheImageViewGone() - } - - } - - fun setVideo(onCompletionListener: GSYSampleCallBack) { - loadCacheImg() - Logger.d(ImageAndVideoRotation.TAG, "setVideo") - mOnCompletionListener = onCompletionListener - //判断是否已经下载 - if (downloadVideoName.isNotEmpty()) { - Logger.d( - ImageAndVideoRotation.TAG, - "video local url = $mVideoDirPath$downloadVideoName" - ) - if (FileUtils.isFileExists(mVideoDirPath + downloadVideoName)) { - Logger.d(ImageAndVideoRotation.TAG, "have cache startPlay") - startPlay(Uri.fromFile(File(mVideoDirPath + downloadVideoName)).toString()) - return - } - startDownLoadVideo() - } - } - - private fun startDownLoadVideo() { - //下载视频, 下载成功后再播放 - Logger.d(ImageAndVideoRotation.TAG, "startDownLoadVideo") - FileUtils.createFileDir(mVideoDirPath) - val downloadUrl = fileNetPath - val downloadDir = mVideoDirPath - if (downloadUrl != null && downloadDir != null) { - DownloadUtils.downLoad( - context, downloadUrl, downloadDir, downloadVideoName, downListener - ) - } - } - - fun startPlay(localVideoPath: String?) { - if (localVideoPath === "") return - try { - Logger.d(ImageAndVideoRotation.TAG, "startPlay") - gsyVideoOptionBuilder = GSYVideoOptionBuilder() - gsyVideoOptionBuilder -// ?.setUrl("file:///mnt/sdcard/downloads/$downloadVideoName") - ?.setUrl(localVideoPath) // "/data/user/0/com.mogo.launcher.f/files/video/" - ?.setPlayTag(downloadVideoName) - ?.setCacheWithPlay(false) - ?.setThumbPlay(false) - ?.build(videoViewPlayer) - - videoViewPlayer?.isFocusableInTouchMode = false - videoViewPlayer?.setVideoAllCallBack(mOnCompletionListener) - videoViewPlayer?.startPlayLogic() - } catch (e: Exception) { - Logger.d(ImageAndVideoRotation.TAG, "startPlay e = ${e.message}") - } - } - - fun onVideoReset() { - videoViewPlayer?.onVideoReset() - mOnCompletionListener = null - } - - fun setPause() { - if (videoViewPlayer !== null) { - videoViewPlayer?.onVideoPause() - } - } - - fun setResume() { - if (videoViewPlayer !== null) { - videoViewPlayer?.onVideoResume() - } - } - - private val downListener = object : IDownloadListener { - override fun onStart(url: String) { - setCacheImageViewVisible() - Logger.d(ImageAndVideoRotation.TAG, "download-onStart") - } - -// override fun onPause(url: String, threadBean: ThreadBean?) { -// Logger.d(ImageAndVideoRotation.TAG, "download-onPause") -//// UiThreadHandler.postDelayed(Runnable { -//// startDownLoadVideo() -//// },DOWNLOAD_DELAY) -// // todo 测试下网络断掉是否会走onpause,且网络回复也不会继续下载 -// } - - override fun onProgress(url: String, downloaded: Long, total: Long) { - Logger.d(ImageAndVideoRotation.TAG, "download-onProgress== ${ (downloaded * 1.0f * 100/total).toInt() }") - } - - override fun onFinished(url: String, path: String) { - Logger.d(ImageAndVideoRotation.TAG, "download-onFinished = $url") - if (url.equals(fileNetPath)) { //发现下载工具在断网又连网后,已完成的任务又都下载,跳转播放出现问题 - //下载完成 - ThreadUtils.runOnUiThread { - startPlay(Uri.fromFile(File(path)).toString()) - } - } else {//如果当前文件不存在再次去下载当前的 - Logger.d( - ImageAndVideoRotation.TAG, "download-onFinished = not current" + - ",currentUrl = $fileNetPath " - ) - if (FileUtils.isFileExists(path)) { - Logger.d(ImageAndVideoRotation.TAG, "have download startPlay") - ThreadUtils.runOnUiThread { - startPlay(Uri.fromFile(File(path)).toString()) - } - return - } else { - startDownLoadVideo() - } - } - } - - override fun onError(url: String, error: String?) { - Logger.d(ImageAndVideoRotation.TAG, "download-onError-$error") - //出错再次下载 - startDownLoadVideo() - } - } -} \ No newline at end of file diff --git a/OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/ui/widget/video/AdvanceViewPager.kt b/OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/ui/widget/video/AdvanceViewPager.kt deleted file mode 100644 index 699247294b..0000000000 --- a/OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/ui/widget/video/AdvanceViewPager.kt +++ /dev/null @@ -1,24 +0,0 @@ -package com.mogo.och.shuttle.passenger.ui.widget.video - -import android.content.Context -import android.util.AttributeSet -import android.view.MotionEvent -import androidx.viewpager.widget.ViewPager - -/** - * @author: wangmingjun - * @date: 2023/2/21 - */ -class AdvanceViewPager: ViewPager{ - - constructor(context: Context) : super(context) - constructor(context: Context,attrs: AttributeSet?) : super(context,attrs) - - override fun onTouchEvent(ev: MotionEvent?): Boolean { - return false - } - - override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean { - return false - } -} \ No newline at end of file diff --git a/OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/ui/widget/video/ImageAndVideoRotation.kt b/OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/ui/widget/video/ImageAndVideoRotation.kt deleted file mode 100644 index bf7a667726..0000000000 --- a/OCH/shuttle/passenger/src/main/java/m2/com/mogo/och/shuttle/passenger/ui/widget/video/ImageAndVideoRotation.kt +++ /dev/null @@ -1,49 +0,0 @@ -package com.mogo.och.shuttle.passenger.ui.widget.video - -import android.annotation.SuppressLint -import android.content.Context -import android.util.AttributeSet -import android.widget.RelativeLayout -import androidx.viewpager.widget.ViewPager -import com.mogo.och.common.module.wigets.video.RotationItem - -/** - * @author: wangmingjun - * @date: 2023/2/6 - */ -class ImageAndVideoRotation @JvmOverloads constructor( - context: Context, attrs: AttributeSet? = null -) : RelativeLayout(context, attrs) { - - private var viewPager: AdvanceViewPager? = null - private var pagerAdapter: AdvancePagerAdapter? = null - - companion object { - const val TAG = "ImageAndVideoRotation" - } - - init { - initView() - } - - @SuppressLint("ClickableViewAccessibility") - private fun initView() { - viewPager = AdvanceViewPager(context) - pagerAdapter = AdvancePagerAdapter(context, viewPager!!) - viewPager?.adapter = pagerAdapter - - addView(viewPager, LayoutParams(-1, -1)) - } - - fun setData(list: MutableList){ - pagerAdapter?.setData(list) - } - - fun setPause(){ - pagerAdapter?.setPause() - } - - fun setResume(){ - pagerAdapter?.setResume() - } -} \ No newline at end of file diff --git a/OCH/shuttle/passenger/src/main/res/m2/layout/shuttle_p_m2_driving_info_fragment.xml b/OCH/shuttle/passenger/src/main/res/m2/layout/shuttle_p_m2_driving_info_fragment.xml index 52e19ded8c..4233460588 100644 --- a/OCH/shuttle/passenger/src/main/res/m2/layout/shuttle_p_m2_driving_info_fragment.xml +++ b/OCH/shuttle/passenger/src/main/res/m2/layout/shuttle_p_m2_driving_info_fragment.xml @@ -285,7 +285,7 @@ app:layout_constraintBottom_toBottomOf="parent" /> - ().apply { - add(TaxiPassengerVideoPlay( - "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708596763/全车型混剪增加红旗车队.m4v", - "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969511280/车队.png", - "蘑菇车联覆盖生活的方方面面" - )) - add(TaxiPassengerVideoPlay( - "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708554279/红旗车队.m4v", - "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969553174/红旗重新排版.png", - "蘑菇车联之红旗车队" - )) - add( - TaxiPassengerVideoPlay( - "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708499497/大运会合作解说版.m4v", - "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969536177/大运会.png", - "蘑菇车联牵手成都大运会" - ) - ) - add( - TaxiPassengerVideoPlay( - "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708409810/20210610重新排版3屏.m4v", - "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969579713/三屏.png", - "多视角体验蘑菇车联自动驾驶" - ) - ) - } - } + private val mediaList = mutableListOf() + //新的数据,在view不展示的时候完成新数据更新 + private val mNewMediaList = mutableListOf() fun exitFullScreenMode(resetVideoPlayer: Boolean) { val carouselLayoutManager = rvVideoPlaylist?.layoutManager as CarouselLayoutManager @@ -83,7 +67,7 @@ internal class InfoVideoView @JvmOverloads constructor( player?.let { it.exitFullScreenMode() it.onVideoPause() - if(resetVideoPlayer) { + if (resetVideoPlayer) { it.onVideoReset() } } @@ -91,12 +75,49 @@ internal class InfoVideoView @JvmOverloads constructor( override fun onAttachedToWindow() { super.onAttachedToWindow() - configPage() + initData() + MediaFileCacheManager.createFileCacheDir(MainMoGoApplication.getApp().applicationContext) + MediaDataSourceManager.init(TAG, object : IMediaDataSourceListener { + override fun onMediaDataSourceChanged(list: List) { + val isNewData = mediaList.isNotEmpty() + MediaPlayLogger.printInfoLog("onMediaDataSourceChanged:isNewData=$isNewData, dataSize=${list.size}, 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) + MediaPlayLogger.printInfoLog("onMediaDataSourceChanged, 宣传视频数据已更新") + } else { + mNewMediaList.clear() + mNewMediaList.addAll(localMediaList) + } + } else { + updateMediaListDataAndView(localMediaList) + MediaPlayLogger.printInfoLog("onMediaDataSourceChanged, 宣传视频数据已更新") + } + } + }) + } + + private fun updateMediaListDataAndView(newList: MutableList) { + mediaList.clear() + mediaList.addAll(newList) + UiThreadHandler.post { + initData() + } } override fun onVisibilityChanged(changedView: View, visibility: Int) { super.onVisibilityChanged(changedView, visibility) - if(changedView!=this){ + if (changedView != this) { return } val carouselLayoutManager = rvVideoPlaylist?.layoutManager as CarouselLayoutManager @@ -109,17 +130,29 @@ internal class InfoVideoView @JvmOverloads constructor( GSYVideoView.CURRENT_STATE_PAUSE -> { //player.onVideoResume(false) } + else -> {} } } } } + else -> { player?.let { if (!player.isIfCurrentIsFullscreen) { player.onVideoPause() } } + try { + // 在播放完成的时机更新整体数据 + if (mNewMediaList.isNotEmpty()) { + updateMediaListDataAndView(mNewMediaList) + mNewMediaList.clear() + MediaPlayLogger.printInfoLog("onVisibilityChanged, 宣传视频数据已更新") + } + } catch (e: Exception) { + e.printStackTrace() + } } } } @@ -130,16 +163,11 @@ internal class InfoVideoView @JvmOverloads constructor( clContain = findViewById(R.id.infoContainer) } - private fun configPage() { -// FullVideoUtils.dismissOverlayView(true) - initData() - } - private fun initData() { val carouselLayoutManager = CarouselLayoutManager(CarouselLayoutManager.HORIZONTAL, true) carouselLayoutManager.setPostLayoutListener(CarouselZoomPostLayoutListener()) carouselLayoutManager.maxVisibleItems = 1 - indicatorView.notifyDataChanged(arrayListOf.size) + indicatorView.notifyDataChanged(mediaList.size) indicatorView.setSlideMode(IndicatorSlideMode.SCALE) indicatorView.setOrientation(IndicatorOrientation.INDICATOR_HORIZONTAL) indicatorView.setIndicatorStyle(IndicatorStyle.ROUND_RECT) @@ -171,6 +199,7 @@ internal class InfoVideoView @JvmOverloads constructor( } } prePlayerPosition = centerItemPosition + MediaPlayLogger.printInfoLog("pageSelect, currentPosition=$prePlayerPosition") } override fun pageStop() { @@ -179,7 +208,6 @@ internal class InfoVideoView @JvmOverloads constructor( player.onVideoPause() } } - }) carouselLayoutManager.addOnDargAutoDiffListener { adapterPosition, currentPosition -> val fl = adapterPosition - floor(adapterPosition) @@ -193,7 +221,7 @@ internal class InfoVideoView @JvmOverloads constructor( } indicatorView.onPageScrolled(currentIndex, fl, 0) } - val recyclerVideoAdapter = RecyclerVideoAdapter(context, arrayListOf, rvVideoPlaylist) + val recyclerVideoAdapter = RecyclerVideoAdapter(context, mediaList, rvVideoPlaylist) recyclerVideoAdapter.setOnThumbImageClilckListener { val (_: Int, player) = getPlayer(carouselLayoutManager) if (player is ConsultVideoPlayer) { @@ -219,14 +247,14 @@ internal class InfoVideoView @JvmOverloads constructor( val carouselLayoutManager = rvVideoPlaylist?.layoutManager as CarouselLayoutManager val (_: Int, player) = getPlayer(carouselLayoutManager) player?.let { - if(it.isInPlayingState&&!it.isIfCurrentIsFullscreen&&!hasWindowFocus){ + if (it.isInPlayingState && !it.isIfCurrentIsFullscreen && !hasWindowFocus) { player.onVideoPause() } } - } override fun onDetachedFromWindow() { + MediaDataSourceManager.unInit(TAG) super.onDetachedFromWindow() } } \ No newline at end of file diff --git a/OCH/taxi/unmanned-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/video/RecyclerVideoAdapter.java b/OCH/taxi/unmanned-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/video/RecyclerVideoAdapter.java index 8b33830ddb..4d9bac7f6d 100644 --- a/OCH/taxi/unmanned-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/video/RecyclerVideoAdapter.java +++ b/OCH/taxi/unmanned-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/video/RecyclerVideoAdapter.java @@ -11,6 +11,7 @@ import androidx.recyclerview.widget.RecyclerView; import com.bumptech.glide.Glide; import com.bumptech.glide.request.RequestOptions; import com.mogo.eagle.core.utilcode.util.ToastUtils; +import com.mogo.och.common.module.wigets.media.MediaItem; import com.mogo.och.taxi.passenger.R; import com.mogo.och.taxi.passenger.bean.TaxiPassengerVideoPlay; import com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack; @@ -48,29 +49,46 @@ public class RecyclerVideoAdapter extends RecyclerView.Adapter { - if(onThumbImageClilckListener!=null){ - onThumbImageClilckListener.onDxChanged(holder.getAbsoluteAdapterPosition()); - } - }); + + if (isVideo) { + holder.gsyVideoPlayer.getThumbImageViewLayout().setOnClickListener(v -> { + if (onThumbImageClilckListener != null) { + onThumbImageClilckListener.onDxChanged(holder.getAbsoluteAdapterPosition()); + } + }); + } else { + holder.gsyVideoPlayer.getThumbImageViewLayout().setOnClickListener(null); + } + holder.gsyVideoPlayer.getTitleTextView().setText(taxiPassengerVideoPlay.getTitle()); + holder.gsyVideoPlayer.getFullscreenButton().setVisibility(isVideo ? View.VISIBLE : View.INVISIBLE); + holder.gsyVideoPlayer.getStartButton().setVisibility(isVideo ? View.VISIBLE : View.INVISIBLE); + holder.gsyVideoPlayer.showOrHideStartPlayButton(isVideo ? true : false); holder.gsyVideoPlayer.setVideoAllCallBack(new GSYSampleCallBack(){ @Override public void onAutoComplete(String url, Object... objects) { @@ -105,13 +123,11 @@ public class RecyclerVideoAdapter extends RecyclerView.Adapter{ start.setImageResource(R.drawable.notice_video_pause) - aivStartPlay.visibility = View.GONE + showOrHideStartPlayButton(false) } else -> { start.setImageResource(R.drawable.notice_video_after_pause) - aivStartPlay.visibility = View.VISIBLE + showOrHideStartPlayButton(true) } } } @@ -527,5 +530,17 @@ class ConsultVideoPlayer : StandardGSYVideoPlayer { fun getVideoAllCallBack(): VideoAllCallBack? { return mVideoAllCallBack } + + fun setFileType(type: Int) { + this.fileType = type + } + + fun showOrHideStartPlayButton(isShow: Boolean) { + if (fileType == MediaItem.MEDIA_TYPE_IMAGE) { + aivStartPlay?.visibility = View.GONE + return + } + aivStartPlay?.visibility = if (isShow ) View.VISIBLE else View.GONE + } } diff --git a/app/build.gradle b/app/build.gradle index bf6d37c52d..87168655f4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -148,26 +148,26 @@ android { dimension "project" buildConfigField 'boolean', 'secure', "true" buildConfigField 'String', 'URLs', "\"${readFileToJson("mogo").replace("\"", "\\\"")}\"" - buildConfigField 'String', 'tempConfig', "\"${readFileToJsonTemp("mogo").replace("\"", "\\\"")}\"" + buildConfigField 'String', 'mediaUrlConfig', "\"${readMediaUrlConfigFromJsonFile("mogo").replace("\"", "\\\"")}\"" } yantai { dimension "project" buildConfigField 'boolean', 'secure', "false" buildConfigField 'String', 'URLs', "\"${readFileToJson("yantai").replace("\"", "\\\"")}\"" - buildConfigField 'String', 'tempConfig', "\"${readFileToJsonTemp("yantai").replace("\"", "\\\"")}\"" + buildConfigField 'String', 'mediaUrlConfig', "\"${readMediaUrlConfigFromJsonFile("yantai").replace("\"", "\\\"")}\"" } dali { dimension "project" buildConfigField 'boolean', 'secure', "false" buildConfigField 'String', 'URLs', "\"${readFileToJson("dali").replace("\"", "\\\"")}\"" - buildConfigField 'String', 'tempConfig', "\"${readFileToJsonTemp("dali").replace("\"", "\\\"")}\"" + buildConfigField 'String', 'mediaUrlConfig', "\"${readMediaUrlConfigFromJsonFile("dali").replace("\"", "\\\"")}\"" } saas { dimension "project" buildConfigField 'boolean', 'secure', "false" buildConfigField 'String', 'URLs', "\"${readFileToJson("saas").replace("\"", "\\\"")}\"" - buildConfigField 'String', 'tempConfig', "\"${readFileToJsonTemp("saas").replace("\"", "\\\"")}\"" + buildConfigField 'String', 'mediaUrlConfig', "\"${readMediaUrlConfigFromJsonFile("saas").replace("\"", "\\\"")}\"" } // 配置网络环境,QA、线上、演示 qa { @@ -395,10 +395,15 @@ def variantName() { } -Object readFileToJsonTemp(env){ +/** + * 读取各车型宣传视频本地配置 + * @param env + * @return + */ +Object readMediaUrlConfigFromJsonFile(env){ try { // 加载config.json 文件 - File file = new File("${rootDir}/app/config/tempConfig.json") + File file = new File("${rootDir}/app/config/MediaUrlConfig.json") def jsonSlurper = new JsonSlurper() // 解析json def config = jsonSlurper.parse(file) diff --git a/app/config/MediaUrlConfig.json b/app/config/MediaUrlConfig.json new file mode 100644 index 0000000000..79a9a68e02 --- /dev/null +++ b/app/config/MediaUrlConfig.json @@ -0,0 +1,714 @@ +{ + "mogo": { + "shuttlepassengerochjl": { + "medias": [ + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357256102/1.jpg", + "fileType": 1, + "coverImageUrl": "", + "title": "1" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png", + "fileType": 1, + "coverImageUrl": "", + "title": "2" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357557335/3.mp4", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png", + "title": "3" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", + "fileType": 1, + "coverImageUrl": "", + "title": "4" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357834634/5.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", + "title": "5" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676358660379/6.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", + "title": "6" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360154589/7.jpg", + "fileType": 1, + "coverImageUrl": "", + "title": "7" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360185500/8.jpg", + "fileType": 1, + "coverImageUrl": "", + "title": "8" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png", + "fileType": 1, + "coverImageUrl": "", + "title": "9" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360274126/10.mp4", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png", + "title": "10" + } + ] + }, + "buspassengerochjl": { + "medias": [ + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357256102/1.jpg", + "fileType": 1, + "coverImageUrl": "", + "title": "1" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png", + "fileType": 1, + "coverImageUrl": "", + "title": "2" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357557335/3.mp4", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png", + "title": "3" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", + "fileType": 1, + "coverImageUrl": "", + "title": "4" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357834634/5.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", + "title": "5" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676358660379/6.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", + "title": "6" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360154589/7.jpg", + "fileType": 1, + "coverImageUrl": "", + "title": "7" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360185500/8.jpg", + "fileType": 1, + "coverImageUrl": "", + "title": "8" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png", + "fileType": 1, + "coverImageUrl": "", + "title": "9" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360274126/10.mp4", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png", + "title": "10" + } + ] + }, + "shuttlepassengerochm2": { + "medias": [ + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1681716116231/6923474a99a1983c9a0410ad3357888d.mov", + "fileType": 2, + "coverImageUrl": "", + "title": "1" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1681716116231/6923474a99a1983c9a0410ad3357888d.mov", + "fileType": 2, + "coverImageUrl": "", + "title": "2" + } + ] + }, + "taxiunmannedpassengerochdfhq": { + "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": "多视角体验蘑菇车联自动驾驶" + } + ] + }, + "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": { + "shuttlepassengerochjl": { + "medias": [ + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357256102/1.jpg", + "fileType": 1, + "coverImageUrl": "", + "title": "1" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png", + "fileType": 1, + "coverImageUrl": "", + "title": "2" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357557335/3.mp4", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png", + "title": "3" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", + "fileType": 1, + "coverImageUrl": "", + "title": "4" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357834634/5.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", + "title": "5" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676358660379/6.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", + "title": "6" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360154589/7.jpg", + "fileType": 1, + "coverImageUrl": "", + "title": "7" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360185500/8.jpg", + "fileType": 1, + "coverImageUrl": "", + "title": "8" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png", + "fileType": 1, + "coverImageUrl": "", + "title": "9" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360274126/10.mp4", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png", + "title": "10" + } + ] + }, + "buspassengerochjl": { + "medias": [ + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357256102/1.jpg", + "fileType": 1, + "coverImageUrl": "", + "title": "1" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png", + "fileType": 1, + "coverImageUrl": "", + "title": "2" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357557335/3.mp4", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png", + "title": "3" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", + "fileType": 1, + "coverImageUrl": "", + "title": "4" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357834634/5.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", + "title": "5" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676358660379/6.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", + "title": "6" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360154589/7.jpg", + "fileType": 1, + "coverImageUrl": "", + "title": "7" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360185500/8.jpg", + "fileType": 1, + "coverImageUrl": "", + "title": "8" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png", + "fileType": 1, + "coverImageUrl": "", + "title": "9" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360274126/10.mp4", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png", + "title": "10" + } + ] + }, + "shuttlepassengerochm2": { + "medias": [ + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1681716116231/6923474a99a1983c9a0410ad3357888d.mov", + "fileType": 2, + "coverImageUrl": "", + "title": "1" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1681716116231/6923474a99a1983c9a0410ad3357888d.mov", + "fileType": 2, + "coverImageUrl": "", + "title": "2" + } + ] + }, + "taxiunmannedpassengerochdfhq": { + "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": "多视角体验蘑菇车联自动驾驶" + } + ] + }, + "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": { + "shuttlepassengerochjl": { + "medias": [ + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1681210971943/yangmadou.mp4", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1680774790614/yangmadao_photo.jpg", + "title": "1" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1681210971943/yangmadou.mp4", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1680774790614/yangmadao_photo.jpg", + "title": "2" + } + ] + }, + "buspassengerochjl": { + "medias": [ + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1681210971943/yangmadou.mp4", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1680774790614/yangmadao_photo.jpg", + "title": "1" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1681210971943/yangmadou.mp4", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1680774790614/yangmadao_photo.jpg", + "title": "2" + } + ] + }, + "shuttlepassengerochm2": { + "medias": [ + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1681716116231/6923474a99a1983c9a0410ad3357888d.mov", + "fileType": 2, + "coverImageUrl": "", + "title": "1" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1681716116231/6923474a99a1983c9a0410ad3357888d.mov", + "fileType": 2, + "coverImageUrl": "", + "title": "2" + } + ] + }, + "taxiunmannedpassengerochdfhq": { + "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": "多视角体验蘑菇车联自动驾驶" + } + ] + }, + "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": { + "shuttlepassengerochjl": { + "medias": [ + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357256102/1.jpg", + "fileType": 1, + "coverImageUrl": "", + "title": "1" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png", + "fileType": 1, + "coverImageUrl": "", + "title": "2" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357557335/3.mp4", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png", + "title": "3" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", + "fileType": 1, + "coverImageUrl": "", + "title": "4" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357834634/5.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", + "title": "5" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676358660379/6.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", + "title": "6" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360154589/7.jpg", + "fileType": 1, + "coverImageUrl": "", + "title": "7" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360185500/8.jpg", + "fileType": 1, + "coverImageUrl": "", + "title": "8" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png", + "fileType": 1, + "coverImageUrl": "", + "title": "9" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360274126/10.mp4", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png", + "title": "10" + } + ] + }, + "buspassengerochjl": { + "medias": [ + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357256102/1.jpg", + "fileType": 1, + "coverImageUrl": "", + "title": "1" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png", + "fileType": 1, + "coverImageUrl": "", + "title": "2" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357557335/3.mp4", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png", + "title": "3" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", + "fileType": 1, + "coverImageUrl": "", + "title": "4" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357834634/5.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", + "title": "5" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676358660379/6.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", + "title": "6" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360154589/7.jpg", + "fileType": 1, + "coverImageUrl": "", + "title": "7" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360185500/8.jpg", + "fileType": 1, + "coverImageUrl": "", + "title": "8" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png", + "fileType": 1, + "coverImageUrl": "", + "title": "9" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360274126/10.mp4", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png", + "title": "10" + } + ] + }, + "shuttlepassengerochm2": { + "medias": [ + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1681716116231/6923474a99a1983c9a0410ad3357888d.mov", + "fileType": 2, + "coverImageUrl": "", + "title": "1" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1681716116231/6923474a99a1983c9a0410ad3357888d.mov", + "fileType": 2, + "coverImageUrl": "", + "title": "2" + } + ] + }, + "taxiunmannedpassengerochdfhq": { + "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": "多视角体验蘑菇车联自动驾驶" + } + ] + }, + "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": "多视角体验蘑菇车联自动驾驶" + } + ] + } + } +} diff --git a/app/config/tempConfig.json b/app/config/tempConfig.json deleted file mode 100644 index 6b5b6e6a76..0000000000 --- a/app/config/tempConfig.json +++ /dev/null @@ -1,490 +0,0 @@ -{ - "mogo": { - "shuttlepassengerochjl": { - "ads": [ - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357256102/1.jpg", - "type": 0, - "cacheImgPath": "", - "title": "1" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png", - "type": 0, - "cacheImgPath": "", - "title": "2" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357557335/3.mp4", - "type": 1, - "cacheImgPath": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png", - "title": "3" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", - "type": 0, - "cacheImgPath": "", - "title": "4" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357834634/5.m4v", - "type": 1, - "cacheImgPath": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", - "title": "5" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676358660379/6.m4v", - "type": 1, - "cacheImgPath": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", - "title": "6" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360154589/7.jpg", - "type": 0, - "cacheImgPath": "", - "title": "7" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360185500/8.jpg", - "type": 0, - "cacheImgPath": "", - "title": "8" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png", - "type": 0, - "cacheImgPath": "", - "title": "9" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360274126/10.mp4", - "type": 1, - "cacheImgPath": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png", - "title": "10" - } - ] - }, - "buspassengerochjl": { - "ads": [ - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357256102/1.jpg", - "type": 0, - "cacheImgPath": "", - "title": "1" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png", - "type": 0, - "cacheImgPath": "", - "title": "2" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357557335/3.mp4", - "type": 1, - "cacheImgPath": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png", - "title": "3" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", - "type": 0, - "cacheImgPath": "", - "title": "4" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357834634/5.m4v", - "type": 1, - "cacheImgPath": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", - "title": "5" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676358660379/6.m4v", - "type": 1, - "cacheImgPath": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", - "title": "6" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360154589/7.jpg", - "type": 0, - "cacheImgPath": "", - "title": "7" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360185500/8.jpg", - "type": 0, - "cacheImgPath": "", - "title": "8" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png", - "type": 0, - "cacheImgPath": "", - "title": "9" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360274126/10.mp4", - "type": 1, - "cacheImgPath": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png", - "title": "10" - } - ] - }, - "shuttlepassengerochm2": { - "ads": [ - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1681716116231/6923474a99a1983c9a0410ad3357888d.mov", - "type": 1, - "cacheImgPath": "", - "title": "1" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1681716116231/6923474a99a1983c9a0410ad3357888d.mov", - "type": 1, - "cacheImgPath": "", - "title": "2" - } - ] - } - }, - "dali": { - "shuttlepassengerochjl": { - "ads": [ - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357256102/1.jpg", - "type": 0, - "cacheImgPath": "", - "title": "1" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png", - "type": 0, - "cacheImgPath": "", - "title": "2" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357557335/3.mp4", - "type": 1, - "cacheImgPath": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png", - "title": "3" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", - "type": 0, - "cacheImgPath": "", - "title": "4" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357834634/5.m4v", - "type": 1, - "cacheImgPath": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", - "title": "5" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676358660379/6.m4v", - "type": 1, - "cacheImgPath": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", - "title": "6" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360154589/7.jpg", - "type": 0, - "cacheImgPath": "", - "title": "7" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360185500/8.jpg", - "type": 0, - "cacheImgPath": "", - "title": "8" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png", - "type": 0, - "cacheImgPath": "", - "title": "9" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360274126/10.mp4", - "type": 1, - "cacheImgPath": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png", - "title": "10" - } - ] - }, - "buspassengerochjl": { - "ads": [ - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357256102/1.jpg", - "type": 0, - "cacheImgPath": "", - "title": "1" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png", - "type": 0, - "cacheImgPath": "", - "title": "2" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357557335/3.mp4", - "type": 1, - "cacheImgPath": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png", - "title": "3" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", - "type": 0, - "cacheImgPath": "", - "title": "4" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357834634/5.m4v", - "type": 1, - "cacheImgPath": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", - "title": "5" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676358660379/6.m4v", - "type": 1, - "cacheImgPath": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", - "title": "6" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360154589/7.jpg", - "type": 0, - "cacheImgPath": "", - "title": "7" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360185500/8.jpg", - "type": 0, - "cacheImgPath": "", - "title": "8" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png", - "type": 0, - "cacheImgPath": "", - "title": "9" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360274126/10.mp4", - "type": 1, - "cacheImgPath": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png", - "title": "10" - } - ] - }, - "shuttlepassengerochm2": { - "ads": [ - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1681716116231/6923474a99a1983c9a0410ad3357888d.mov", - "type": 1, - "cacheImgPath": "", - "title": "1" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1681716116231/6923474a99a1983c9a0410ad3357888d.mov", - "type": 1, - "cacheImgPath": "", - "title": "2" - } - ] - } - }, - "yantai": { - "shuttlepassengerochjl": { - "ads": [ - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1681210971943/yangmadou.mp4", - "type": 1, - "cacheImgPath": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1680774790614/yangmadao_photo.jpg", - "title": "1" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1681210971943/yangmadou.mp4", - "type": 1, - "cacheImgPath": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1680774790614/yangmadao_photo.jpg", - "title": "2" - } - ] - }, - "buspassengerochjl": { - "ads": [ - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1681210971943/yangmadou.mp4", - "type": 1, - "cacheImgPath": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1680774790614/yangmadao_photo.jpg", - "title": "1" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1681210971943/yangmadou.mp4", - "type": 1, - "cacheImgPath": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1680774790614/yangmadao_photo.jpg", - "title": "2" - } - ] - }, - "shuttlepassengerochm2": { - "ads": [ - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1681716116231/6923474a99a1983c9a0410ad3357888d.mov", - "type": 1, - "cacheImgPath": "", - "title": "1" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1681716116231/6923474a99a1983c9a0410ad3357888d.mov", - "type": 1, - "cacheImgPath": "", - "title": "2" - } - ] - } - }, - "saas": { - "shuttlepassenger": { - "ads": [ - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357256102/1.jpg", - "type": 0, - "cacheImgPath": "", - "title": "1" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png", - "type": 0, - "cacheImgPath": "", - "title": "2" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357557335/3.mp4", - "type": 1, - "cacheImgPath": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png", - "title": "3" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", - "type": 0, - "cacheImgPath": "", - "title": "4" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357834634/5.m4v", - "type": 1, - "cacheImgPath": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", - "title": "5" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676358660379/6.m4v", - "type": 1, - "cacheImgPath": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", - "title": "6" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360154589/7.jpg", - "type": 0, - "cacheImgPath": "", - "title": "7" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360185500/8.jpg", - "type": 0, - "cacheImgPath": "", - "title": "8" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png", - "type": 0, - "cacheImgPath": "", - "title": "9" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360274126/10.mp4", - "type": 1, - "cacheImgPath": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png", - "title": "10" - } - ] - }, - "buspassenger": { - "ads": [ - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357256102/1.jpg", - "type": 0, - "cacheImgPath": "", - "title": "1" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png", - "type": 0, - "cacheImgPath": "", - "title": "2" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357557335/3.mp4", - "type": 1, - "cacheImgPath": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png", - "title": "3" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", - "type": 0, - "cacheImgPath": "", - "title": "4" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357834634/5.m4v", - "type": 1, - "cacheImgPath": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", - "title": "5" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676358660379/6.m4v", - "type": 1, - "cacheImgPath": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", - "title": "6" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360154589/7.jpg", - "type": 0, - "cacheImgPath": "", - "title": "7" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360185500/8.jpg", - "type": 0, - "cacheImgPath": "", - "title": "8" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png", - "type": 0, - "cacheImgPath": "", - "title": "9" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360274126/10.mp4", - "type": 1, - "cacheImgPath": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png", - "title": "10" - } - ] - }, - "shuttlepassengerm2": { - "ads": [ - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1681716116231/6923474a99a1983c9a0410ad3357888d.mov", - "type": 1, - "cacheImgPath": "", - "title": "1" - }, - { - "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1681716116231/6923474a99a1983c9a0410ad3357888d.mov", - "type": 1, - "cacheImgPath": "", - "title": "2" - } - ] - } - } -} diff --git a/app/src/main/java/com/mogo/launcher/startup/ConfigStartUp.kt b/app/src/main/java/com/mogo/launcher/startup/ConfigStartUp.kt index df60093489..6d0db996c1 100644 --- a/app/src/main/java/com/mogo/launcher/startup/ConfigStartUp.kt +++ b/app/src/main/java/com/mogo/launcher/startup/ConfigStartUp.kt @@ -46,8 +46,8 @@ object ConfigStartUp { FunctionBuildConfig.urlJson = GsonUtils.fromJson(BuildConfig.URLs, UrlConfig::class.java) //不能启动自动驾驶的档位 FunctionBuildConfig.unableLaunchAutopilotGear = BuildConfig.UNABLE_LAUNCH_AUTOPILOT_GEAR - // 临时配置json - FunctionBuildConfig.tempConfig = BuildConfig.tempConfig + // 各车型宣传视频本地配置json + FunctionBuildConfig.mediaUrlConfig = BuildConfig.mediaUrlConfig //是否支持Patch升级 FunctionBuildConfig.isSupportPatchUpgrade = BuildConfig.IS_SUPPORT_PATCH_UPGRADE diff --git a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/config/FunctionBuildConfig.kt b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/config/FunctionBuildConfig.kt index 3a05863c22..77412a2db3 100644 --- a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/config/FunctionBuildConfig.kt +++ b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/config/FunctionBuildConfig.kt @@ -120,13 +120,12 @@ object FunctionBuildConfig { var appIdentityMode = "Taxi_Driver_Base" /** - * 临时配置json + * 各车型宣传视频本地配置 * 广告json - * */ @Volatile @JvmField - var tempConfig = "" + var mediaUrlConfig = "" /**