From 606cab9fe05b8549b47df14fb976d958114774c5 Mon Sep 17 00:00:00 2001 From: aibingbing Date: Mon, 11 Dec 2023 20:09:50 +0800 Subject: [PATCH 01/13] =?UTF-8?q?[=E5=AE=A3=E4=BC=A0=E8=A7=86=E9=A2=91]=20?= =?UTF-8?q?refactor:=20=E5=AE=A3=E4=BC=A0=E8=A7=86=E9=A2=91=E6=92=AD?= =?UTF-8?q?=E6=94=BE=E9=87=8D=E6=9E=84=20step1=20;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/module/wigets/video/AdsDatas.kt | 19 +- .../wigets/video/ImageVideoRotationView.kt | 44 --- .../module/wigets/video/MediaLoopPlayView.kt | 288 ++++++++++++++++++ .../wigets/video/VideoPlayerFragment.kt | 14 +- .../module/wigets/video/VideoPlayerView.kt | 287 +++-------------- .../main/res/layout/fragment_video_player.xml | 4 +- .../passenger/ui/video/PM2VideoFragment.kt | 4 +- .../ui/widget/video/AdvancePagerAdapter.kt | 8 +- .../ui/widget/video/ImageAndVideoRotation.kt | 5 +- 9 files changed, 363 insertions(+), 310 deletions(-) delete mode 100644 OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/ImageVideoRotationView.kt create mode 100644 OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/MediaLoopPlayView.kt diff --git a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/AdsDatas.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/AdsDatas.kt index 777f13a502..c159360ffe 100644 --- a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/AdsDatas.kt +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/AdsDatas.kt @@ -1,10 +1,23 @@ package com.mogo.och.common.module.wigets.video -data class AdsDatas(val ads:MutableList) +data class AdsDatas(val ads: MutableList) -data class RotationItem( +data class MediaItem( var path: String, var type: Int, var cacheImgPath: String, var title: String -) +) { + companion object { + const val MEDIA_TYPE_IMAGE = 0 + const val MEDIA_TYPE_VIDEO = 1 + } + + fun isImageType(): Boolean { + return this.type == MEDIA_TYPE_IMAGE + } + + fun isVideoType(): Boolean { + return this.type == MEDIA_TYPE_VIDEO + } +} diff --git a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/ImageVideoRotationView.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/ImageVideoRotationView.kt deleted file mode 100644 index cdf8741b67..0000000000 --- a/OCH/mogo-och-common-module/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/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/MediaLoopPlayView.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/MediaLoopPlayView.kt new file mode 100644 index 0000000000..5a5b7d9b45 --- /dev/null +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/MediaLoopPlayView.kt @@ -0,0 +1,288 @@ +package com.mogo.och.common.module.wigets.video + +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.shuyu.gsyvideoplayer.listener.GSYSampleCallBack + +class MediaLoopPlayView @JvmOverloads constructor( + context: Context, attrs: AttributeSet? = null +) : RelativeLayout(context, attrs) { + + companion object { + const val TAG = "MediaLoopPlayView" + } + + 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 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 var mLastViewPagerPosition = -1 + private var mImageCountDownTimer: CountDownTimer? = null + + fun setMediaData(list: MutableList) { + if (list.isEmpty()) { + CallerLogger.d(MediaLoopPlayView.TAG, "setMediaData, list为空") + return + } + + mDataList.addAll(list) + mItemViewList.clear() + list.forEach { + addItemView(it) + } + + mViewPager.addOnPageChangeListener(this) + notifyDataSetChanged() + mViewPager.currentItem = 0 + + if (mItemViewList.size > 0) { + startLoopPlay() + } + } + + 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, `object`: Any) { + container.removeView(mItemViewList[position]) + } + + 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.setImagePath(item.path) + mItemViewList.add(imageView) + } else if (item.isVideoType()) { + val videoView = AdvanceVideoView(mContext) + videoView.setVideoPath(item.path, item.cacheImgPath) + mItemViewList.add(videoView) + } else { + CallerLogger.d(MediaLoopPlayView.TAG, "addItemView 不支持的文件类型:${item.type}") + } + } + + /** + * 开始播放循环 + * 1.如果是视频,开始播放视频,等到播放完成后根据media类型开始播放下一个 + * 2.如果是图片,展示图片,同时开始timer倒计时,倒计时完时根据media类型开始播放下一个 + */ + private fun startLoopPlay() { + val currentPosition = mViewPager.currentItem + val currentMediaItem = mDataList[currentPosition] + if (mItemViewList[currentPosition] is AdvanceVideoView) { + CallerLogger.d( + MediaLoopPlayView.TAG, + "startLoopPlay: AdvanceVideoView, url=${currentMediaItem.path}" + ) + val videoView = mItemViewList[currentPosition] as AdvanceVideoView + videoView.setCacheImageViewVisible() + videoView.setVideo(videoPlayLifecycleCallBack) + } else if (mItemViewList[currentPosition] is AdvanceImageView) { + CallerLogger.d( + MediaLoopPlayView.TAG, + "startLoopPlay: AdvanceImageView, url=${currentMediaItem.path}" + ) + startImageCountDownTimer() + } else { + CallerLogger.d( + MediaLoopPlayView.TAG, + "startLoopPlay 不支持的文件类型:${currentMediaItem.type}, url=${currentMediaItem.path}" + ) + } + } + + 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(5000L, 1000L) { + override fun onTick(millisUntilFinished: Long) { + CallerLogger.d( + MediaLoopPlayView.TAG, + "mImageCountDownTimer倒计时秒, countDown=${millisUntilFinished / 1000}" + ) + } + + override fun onFinish() { + CallerLogger.d(MediaLoopPlayView.TAG, "mImageCountDownTimer倒计时秒, onFinish") + playNextItemView(false) + } + }.start() + } + + private fun cancelImageCountDownTimer() { + if (mImageCountDownTimer != null) { + mImageCountDownTimer?.cancel() + mImageCountDownTimer = null + } + } + + /** + * 根据当前item情况,播放下一个item + */ + private fun playNextItemView(isOnVideoError: Boolean) { + val currentPosition = mViewPager.currentItem + val currentMediaItem = mDataList[currentPosition] + val currentItemView = mItemViewList[currentPosition] + CallerLogger.d( + MediaLoopPlayView.TAG, + "playNextItemView, currentPosition=$currentPosition, type=${currentMediaItem.type}, url=${currentMediaItem.path}" + ) + if (currentItemView is AdvanceVideoView) { + currentItemView.onVideoReset() + //videoView.setCacheImageViewVisible() + if (isOnVideoError) { + currentItemView.clearLocalErrorVideo() + } + if (mItemViewList.size == 1) { + currentItemView.startPlay(currentMediaItem.path) + return + } + } + if (currentPosition == mItemViewList.size - 1) { + //已经到最后一个, 从头开始 + mViewPager.post { + mViewPager.setCurrentItem(0, true) + } + } else { + mViewPager.post { + mViewPager.setCurrentItem(mViewPager.currentItem + 1, true) + } + } + } + + fun setPause() { + if (mItemViewList.size <= 0) { + return + } + val currentPosition = mViewPager.currentItem + if (mItemViewList[currentPosition] is AdvanceVideoView) { + val videoView = mItemViewList[mViewPager.currentItem] as AdvanceVideoView + videoView.setPause() + } else if (mItemViewList[currentPosition] is AdvanceImageView) { + cancelImageCountDownTimer() + } + } + + fun setResume() { + if (mItemViewList.size <= 0) { + return + } + val currentPosition = mViewPager.currentItem + if (mItemViewList[currentPosition] is AdvanceVideoView) { + val videoView = mItemViewList[mViewPager.currentItem] as AdvanceVideoView + videoView.setResume() + } 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/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerFragment.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerFragment.kt index 1e1a3cbd17..3748d81cf8 100644 --- a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerFragment.kt +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerFragment.kt @@ -6,7 +6,7 @@ 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.* +import kotlinx.android.synthetic.main.fragment_video_player.imageVideoRotationView /** * @author: wangmingjun @@ -15,7 +15,11 @@ import kotlinx.android.synthetic.main.fragment_video_player.* class VideoPlayerFragment : MvpFragment() { - private var arrayListOf = mutableListOf() + companion object { + private val TAG = VideoPlayerFragment::class.java.simpleName + } + + private var arrayListOf = mutableListOf() override fun getLayoutId(): Int { return R.layout.fragment_video_player @@ -25,17 +29,13 @@ class VideoPlayerFragment : 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) + imageVideoRotationView.setMediaData(arrayListOf) } override fun onPause() { diff --git a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerView.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerView.kt index b61739f75b..520e2c2318 100644 --- a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerView.kt +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerView.kt @@ -3,32 +3,24 @@ 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.eagle.core.widget.media.video.TextureVideoViewOutlineProvider 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.mogo.och.common.module.wigets.video.MediaLoopPlayView 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 me.jessyan.autosize.utils.AutoSizeUtils import java.io.File class AdvanceVideoView @JvmOverloads constructor( @@ -94,18 +86,18 @@ class AdvanceVideoView @JvmOverloads constructor( 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) - } + Logger.d(MediaLoopPlayView.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() { @@ -131,16 +123,16 @@ class AdvanceVideoView @JvmOverloads constructor( fun setVideo(onCompletionListener: GSYSampleCallBack) { loadCacheImg() - Logger.d(ImageVideoRotationView.TAG, "setVideo") + Logger.d(MediaLoopPlayView.TAG, "setVideo") mOnCompletionListener = onCompletionListener //判断是否已经下载 if (downloadVideoName.isNotEmpty()) { Logger.d( - ImageVideoRotationView.TAG, + MediaLoopPlayView.TAG, "video local url = $mVideoDirPath$downloadVideoName" ) if (FileUtils.isFileExists(mVideoDirPath + downloadVideoName)) { - Logger.d(ImageVideoRotationView.TAG, "have cache startPlay") + Logger.d(MediaLoopPlayView.TAG, "have cache startPlay") startPlay(Uri.fromFile(File(mVideoDirPath + downloadVideoName)).toString()) return } @@ -150,15 +142,20 @@ class AdvanceVideoView @JvmOverloads constructor( private fun startDownLoadVideo() { //下载视频, 下载成功后再播放 - Logger.d(ImageVideoRotationView.TAG, "startDownLoadVideo") + Logger.d(MediaLoopPlayView.TAG, "startDownLoadVideo") FileUtils.createFileDir(mVideoDirPath) - DownloadUtils.downLoad( - context, fileNetPath!!, mVideoDirPath!!, downloadVideoName, downListener) + val downloadUrl = fileNetPath + val downloadDir = mVideoDirPath + if (downloadUrl != null && downloadDir != null) { + DownloadUtils.downLoad( + context, downloadUrl, downloadDir, downloadVideoName, downListener + ) + } } fun startPlay(localVideoPath: String?) { try { - Logger.d(ImageVideoRotationView.TAG, "startPlay") + Logger.d(MediaLoopPlayView.TAG, "startPlay") gsyVideoOptionBuilder = GSYVideoOptionBuilder() gsyVideoOptionBuilder ?.setUrl( @@ -173,7 +170,7 @@ class AdvanceVideoView @JvmOverloads constructor( videoViewPlayer?.setVideoAllCallBack(mOnCompletionListener) videoViewPlayer?.startPlayLogic() } catch (e: Exception) { - Logger.d(ImageVideoRotationView.TAG, "startPlay e = ${e.message}") + Logger.d(MediaLoopPlayView.TAG, "startPlay e = ${e.message}") } } @@ -198,15 +195,15 @@ class AdvanceVideoView @JvmOverloads constructor( override fun onStart(url: String) { setCacheImageViewVisible() - Logger.d(ImageVideoRotationView.TAG, "download-onStart") + Logger.d(MediaLoopPlayView.TAG, "download-onStart") } override fun onProgress(url: String, downloaded: Long, total: Long) { - Logger.d(ImageVideoRotationView.TAG, "download-onProgress== ${ (downloaded * 100 / total).toInt() }") + Logger.d(MediaLoopPlayView.TAG, "download-onProgress== ${ (downloaded * 100 / total).toInt() }") } override fun onFinished(url: String, path: String) { - Logger.d(ImageVideoRotationView.TAG, "download-onFinished = $url") + Logger.d(MediaLoopPlayView.TAG, "download-onFinished = $url") if (url == fileNetPath) { //发现下载工具在断网又连网后,已完成的任务又都下载,跳转播放出现问题 //下载完成 ThreadUtils.runOnUiThread { @@ -214,11 +211,11 @@ class AdvanceVideoView @JvmOverloads constructor( } } else {//如果当前文件不存在再次去下载当前的 Logger.d( - ImageVideoRotationView.TAG, "download-onFinished = not current" + + MediaLoopPlayView.TAG, "download-onFinished = not current" + ",currentUrl = $fileNetPath " ) if (FileUtils.isFileExists(path)) { - Logger.d(ImageVideoRotationView.TAG, "have download startPlay") + Logger.d(MediaLoopPlayView.TAG, "have download startPlay") ThreadUtils.runOnUiThread { startPlay(Uri.fromFile(File(path)).toString()) } @@ -230,220 +227,13 @@ class AdvanceVideoView @JvmOverloads constructor( } override fun onError(url: String, error: String?) { - Logger.d(ImageVideoRotationView.TAG, "download-onError-$error") + Logger.d(MediaLoopPlayView.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) { @@ -586,4 +376,13 @@ class AdvanceGSYVideoPlayer : StandardGSYVideoPlayer { 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/mogo-och-common-module/src/main/res/layout/fragment_video_player.xml b/OCH/mogo-och-common-module/src/main/res/layout/fragment_video_player.xml index 44c0c0702f..7144571ef4 100644 --- a/OCH/mogo-och-common-module/src/main/res/layout/fragment_video_player.xml +++ b/OCH/mogo-och-common-module/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/m2/java/com/mogo/och/bus/passenger/ui/video/PM2VideoFragment.kt b/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/video/PM2VideoFragment.kt index 6b6767c0e6..0d6923b72b 100644 --- a/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/video/PM2VideoFragment.kt +++ b/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/video/PM2VideoFragment.kt @@ -7,7 +7,7 @@ import com.mogo.eagle.core.utilcode.util.GsonUtils import com.mogo.och.bus.passenger.R import com.mogo.och.bus.passenger.presenter.PM2VideoPresenter import com.mogo.och.common.module.wigets.video.AdsDatas -import com.mogo.och.common.module.wigets.video.RotationItem +import com.mogo.och.common.module.wigets.video.MediaItem import kotlinx.android.synthetic.m2.p_m2_video_fragment.* /** @@ -17,7 +17,7 @@ import kotlinx.android.synthetic.m2.p_m2_video_fragment.* class PM2VideoFragment : MvpFragment() { - private var arrayListOf = mutableListOf() + private var arrayListOf = mutableListOf() override fun getLayoutId(): Int { return R.layout.p_m2_video_fragment diff --git a/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvancePagerAdapter.kt b/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvancePagerAdapter.kt index 2d68d3b34d..4d1784a7c3 100644 --- a/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvancePagerAdapter.kt +++ b/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvancePagerAdapter.kt @@ -9,7 +9,7 @@ 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.mogo.och.common.module.wigets.video.MediaItem import com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack /** @@ -22,7 +22,7 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter private val mContext: Context = context private val mViewPager: ViewPager = viewPager - private var dataList = mutableListOf() + private var dataList = mutableListOf() private var viewList = mutableListOf() private var lastPosition = -1 @@ -32,7 +32,7 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter private var pause = false private var countDownTimer: CountDownTimer? = null - fun setData(list: MutableList) { + fun setData(list: MutableList) { if (list.isEmpty()) return dataList.addAll(list) @@ -85,7 +85,7 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter return POSITION_NONE } - private fun addView(item: RotationItem) { + private fun addView(item: MediaItem) { if (item.type == 1) { // 表示视频 val videoView = AdvanceVideoView(mContext) videoView.setVideoPath(item.path,item.cacheImgPath) diff --git a/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/ImageAndVideoRotation.kt b/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/ImageAndVideoRotation.kt index 02205dd945..8b53b3d894 100644 --- a/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/ImageAndVideoRotation.kt +++ b/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/ImageAndVideoRotation.kt @@ -4,8 +4,7 @@ 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 +import com.mogo.och.common.module.wigets.video.MediaItem /** * @author: wangmingjun @@ -35,7 +34,7 @@ class ImageAndVideoRotation @JvmOverloads constructor( addView(viewPager, LayoutParams(-1, -1)) } - fun setData(list: MutableList){ + fun setData(list: MutableList){ pagerAdapter?.setData(list) } From 600548ea9d698dcbdfc95df827744d0a75affe04 Mon Sep 17 00:00:00 2001 From: aibingbing Date: Tue, 12 Dec 2023 18:12:13 +0800 Subject: [PATCH 02/13] =?UTF-8?q?[=E5=AE=A3=E4=BC=A0=E8=A7=86=E9=A2=91]=20?= =?UTF-8?q?refactor:=20=E5=AE=A3=E4=BC=A0=E8=A7=86=E9=A2=91=E6=92=AD?= =?UTF-8?q?=E6=94=BE=E9=87=8D=E6=9E=84=20step2=20;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/biz/constant/OchCommonConst.kt | 6 + .../video/{AdsDatas.kt => MediaBean.kt} | 2 +- .../wigets/video/MediaDataSourceManager.kt | 258 ++++++++++++++++++ .../module/wigets/video/MediaLoopPlayView.kt | 34 ++- .../wigets/video/VideoPlayerFragment.kt | 33 ++- .../passenger/ui/video/PM2VideoFragment.kt | 4 +- app/config/tempConfig.json | 6 +- 7 files changed, 323 insertions(+), 20 deletions(-) rename OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/{AdsDatas.kt => MediaBean.kt} (88%) create mode 100644 OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/MediaDataSourceManager.kt diff --git a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/biz/constant/OchCommonConst.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/biz/constant/OchCommonConst.kt index e110fa20ec..e6fec1f2d5 100644 --- a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/biz/constant/OchCommonConst.kt +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/biz/constant/OchCommonConst.kt @@ -19,6 +19,12 @@ class OchCommonConst { fun getSweeperUrl(): String { return FunctionBuildConfig.urlJson.sweeperUrl } + + @JvmStatic + fun getEagleMisUrl(): String { + return FunctionBuildConfig.urlJson.eagleMisUrl + } + // token 失效 重新获取token const val WAIT_TAKEN = 100046 diff --git a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/AdsDatas.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/MediaBean.kt similarity index 88% rename from OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/AdsDatas.kt rename to OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/MediaBean.kt index c159360ffe..25bc768391 100644 --- a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/AdsDatas.kt +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/MediaBean.kt @@ -1,6 +1,6 @@ package com.mogo.och.common.module.wigets.video -data class AdsDatas(val ads: MutableList) +data class MediaDataList(val ads: MutableList) data class MediaItem( var path: String, diff --git a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/MediaDataSourceManager.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/MediaDataSourceManager.kt new file mode 100644 index 0000000000..f893fff92b --- /dev/null +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/MediaDataSourceManager.kt @@ -0,0 +1,258 @@ +package com.mogo.och.common.module.wigets.video + +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.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.mogo.logger.CallerLogger +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.video.MediaItem.Companion.MEDIA_TYPE_IMAGE +import com.mogo.och.common.module.wigets.video.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.请求管理后台数据成功后:间隔10分钟再次检查 + */ +object AdDataSourceManager { + private val TAG = AdDataSourceManager::class.java.simpleName + + private const val RETRY_MAX_COUNT = 5 + + private var mRetryCount = 0 + + private val mNetworkService: IAdNetworkApi = + MoGoRetrofitFactory.getInstance(OchCommonConst.getEagleMisUrl()) + .create(IAdNetworkApi::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 mLastAdDataSourceList = mutableListOf() + + private var mHasEverGetAdDataFromMis = false + + private val mAdDataSourceListenerMap: ConcurrentHashMap = + ConcurrentHashMap() + + private val getAdDataSourceLoopRunnable = Runnable { + startGetAdDataSourceLoop() + } + + fun init(tag: String, dataSourceListener: IAdDataSourceListener) { + if (!mAdDataSourceListenerMap.containsKey(tag)) { + mAdDataSourceListenerMap[tag] = dataSourceListener + } + startGetAdDataSourceLoop() + } + + fun unInit(tag: String) { + removeGetAdDataSourceLoop() + if (mAdDataSourceListenerMap.containsKey(tag)) { + mAdDataSourceListenerMap.remove(tag) + } + } + + @SuppressLint("MissingPermission") + private fun startGetAdDataSourceLoop() { + removeGetAdDataSourceLoop() + // 失败3次,且从来没有从MIS获取配置信息成功过,先试用本地数据播放 + if (mRetryCount == RETRY_MAX_COUNT && !mHasEverGetAdDataFromMis) { + val localAdDataList = getAdDataFromLocalConfig() + updateAdDataSource(localAdDataList) + CallerLogger.e(TAG, + "startGetAdDataSourceLoop:失败${mRetryCount}次,先使用本地数据播放" + ) + } + if (driverSn.isBlank()) { + CallerLogger.e(TAG, "startGetAdDataSourceLoop:司机屏sn为空,跳过本次查询" + ) + mRetryCount++ + UiThreadHandler.postDelayed(getAdDataSourceLoopRunnable, 1000L) + return + } + if (!NetworkUtils.isConnected()) { + CallerLogger.e(TAG, "startGetAdDataSourceLoop:当前无网络,跳过本次查询" + ) + mRetryCount++ + UiThreadHandler.postDelayed(getAdDataSourceLoopRunnable, 1000L) + return + } + getAdDataFromMis(object : OchCommonServiceCallback { + override fun onSuccess(data: AdDataResp?) { + mHasEverGetAdDataFromMis = true + CallerLogger.e(TAG, + "startGetAdDataSourceLoop:success, 从管理后台获取到数据,AdData=${ + GsonUtils.toJson( + data + ) + }" + ) + val newDataList = AdDataResp.toMediaItemList(data?.data) + // 管理平台如果配置数据为空,不更新 + if (newDataList.isNotEmpty()) { + if (compareAdDataSource(newDataList)) { + updateAdDataSource(newDataList) + CallerLogger.e(TAG, + "startGetAdDataSourceLoop:success, 从管理后台获取到数据,更新数据" + ) + } else { + CallerLogger.e(TAG, + "startGetAdDataSourceLoop:success, 从管理后台获取到数据,数据无变化" + ) + } + } + // 获取成功后,延迟5分钟再查询 + UiThreadHandler.postDelayed(getAdDataSourceLoopRunnable, 5 * 60 * 1000L) + } + + override fun onFail(code: Int, msg: String?) { + CallerLogger.e(TAG, + "startGetAdDataSourceLoop:failed, code=$code, msg=$msg" + ) + mRetryCount++ + val delay = if (mHasEverGetAdDataFromMis) 5000L else 1000L + UiThreadHandler.postDelayed(getAdDataSourceLoopRunnable, delay) + } + + override fun onError() { + super.onError() + CallerLogger.e(TAG, "startGetAdDataSourceLoop:error, 网络异常" + ) + mRetryCount++ + val delay = if (mHasEverGetAdDataFromMis) 5000L else 1000L + UiThreadHandler.postDelayed(getAdDataSourceLoopRunnable, delay) + } + }) + } + + private fun removeGetAdDataSourceLoop() { + UiThreadHandler.removeCallbacks(getAdDataSourceLoopRunnable) + } + + private fun getAdDataFromMis(callback: OchCommonServiceCallback) { + CallerLogger.d(TAG, "getAdDataFromMis:准备发送请求,driverSn=$driverSn" + ) + mNetworkService.queryAdDataFromMis( + sn = driverSn, + screenType = "2", + ).transformTry().subscribe(OchCommonSubscribeImpl(context, callback, "getAdDataFromMis")) + } + + private fun getAdDataFromLocalConfig(): List { + val localAdDataList = mutableListOf() + try { + val datas: MediaDataList = GsonUtils.fromJson( + FunctionBuildConfig.tempConfig, object : TypeToken() {}.type + ) + localAdDataList.addAll(datas.ads) + } catch (e: Exception) { + e.printStackTrace() + } + return localAdDataList + } + + private fun compareAdDataSource(newDataList: List): Boolean { + if (mLastAdDataSourceList.isEmpty() && newDataList.isNotEmpty()) { + return true + } + if (mLastAdDataSourceList.size != newDataList.size) { + return true + } + try { + newDataList.forEachIndexed { index, rotationItem -> + val oldIndexItem = mLastAdDataSourceList[index] + if (rotationItem?.path != oldIndexItem?.path) { + return true + } + } + } catch (e: Exception) { + e.printStackTrace() + } + return false + } + + private fun updateAdDataSource(newDataList: List) { + mLastAdDataSourceList.clear() + mLastAdDataSourceList.addAll(newDataList) + mAdDataSourceListenerMap.forEach { + val listener = it.value + listener.onAdDataSourceChanged(newDataList) + } + } + +} + +interface IAdDataSourceListener { + fun onAdDataSourceChanged(list: List) +} + +interface IAdNetworkApi { + @Headers("Content-type:application/json;charset=UTF-8") + @GET("/platform/biz/adv/screen/advs") + fun queryAdDataFromMis( + @Query("sn") sn: String, + @Query("screenType") screenType: String + ): Observable +} + +data class AdData( + 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 AdDataResp(val data: List) : BaseData() { + companion object { + fun toMediaItemList(adDataList: List?): List { + val rotationItemList = mutableListOf() + adDataList?.forEach { + val rotationItem = MediaItem( + path = if (TextUtils.isEmpty(it.file_path)) "" else "${it.file_path}", + type = if (it.file_type == 1) MEDIA_TYPE_VIDEO else MEDIA_TYPE_IMAGE, + cacheImgPath = 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/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/MediaLoopPlayView.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/MediaLoopPlayView.kt index 5a5b7d9b45..68c824818d 100644 --- a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/MediaLoopPlayView.kt +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/MediaLoopPlayView.kt @@ -12,6 +12,8 @@ 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.video.MediaLoopPlayView.Companion.IMAGE_COUNT_DOWN_SECONDS import com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack class MediaLoopPlayView @JvmOverloads constructor( @@ -20,6 +22,7 @@ class MediaLoopPlayView @JvmOverloads constructor( companion object { const val TAG = "MediaLoopPlayView" + const val IMAGE_COUNT_DOWN_SECONDS = 5 } private var viewPager: AdvanceViewPager? = null @@ -40,6 +43,10 @@ class MediaLoopPlayView @JvmOverloads constructor( pagerAdapter?.setMediaData(list) } + fun setNewMediaData(list: MutableList){ + pagerAdapter?.setNewMediaData(list) + } + fun setPause() { pagerAdapter?.setPause() } @@ -70,6 +77,8 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter private var mDataList = mutableListOf() private var mItemViewList = mutableListOf() + //新的数据,在轮播下一次切换的时机完成整体数据的更新 + private val mNewDataList: MutableList = mutableListOf() private var mLastViewPagerPosition = -1 private var mImageCountDownTimer: CountDownTimer? = null @@ -80,6 +89,7 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter return } + mDataList.clear() mDataList.addAll(list) mItemViewList.clear() list.forEach { @@ -95,6 +105,11 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter } } + fun setNewMediaData(list: MutableList){ + mNewDataList.clear() + mNewDataList.addAll(list) + } + override fun getCount(): Int { return mDataList.size } @@ -103,8 +118,13 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter return view === `object` } - override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) { - container.removeView(mItemViewList[position]) + 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 { @@ -184,7 +204,7 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter mImageCountDownTimer?.cancel() mImageCountDownTimer = null } - mImageCountDownTimer = object : CountDownTimer(5000L, 1000L) { + mImageCountDownTimer = object : CountDownTimer(IMAGE_COUNT_DOWN_SECONDS * 1000L, 1000L) { override fun onTick(millisUntilFinished: Long) { CallerLogger.d( MediaLoopPlayView.TAG, @@ -210,6 +230,14 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter * 根据当前item情况,播放下一个item */ private fun playNextItemView(isOnVideoError: Boolean) { + // 在播放完成的时机更新整体数据 + if (mNewDataList.isNotEmpty()) { + setMediaData(mNewDataList) + mNewDataList.clear() + ToastUtils.showShort("宣传视频数据已更新") + return + } + val currentPosition = mViewPager.currentItem val currentMediaItem = mDataList[currentPosition] val currentItemView = mItemViewList[currentPosition] diff --git a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerFragment.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerFragment.kt index 3748d81cf8..ba5ac18a4f 100644 --- a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerFragment.kt +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerFragment.kt @@ -1,10 +1,10 @@ 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.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 @@ -34,8 +34,23 @@ class VideoPlayerFragment : } override fun initViews() { - initResourceData() - imageVideoRotationView.setMediaData(arrayListOf) + AdDataSourceManager.init(TAG, object : IAdDataSourceListener { + override fun onAdDataSourceChanged(list: List) { + val isNewData = arrayListOf.isNotEmpty() + CallerLogger.d( + TAG, "onAdDataSourceChanged: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() { @@ -48,13 +63,9 @@ class VideoPlayerFragment : 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) { - } + override fun onDestroy() { + AdDataSourceManager.unInit(TAG) + super.onDestroy() } } diff --git a/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/video/PM2VideoFragment.kt b/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/video/PM2VideoFragment.kt index 0d6923b72b..26fbd734d2 100644 --- a/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/video/PM2VideoFragment.kt +++ b/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/video/PM2VideoFragment.kt @@ -6,7 +6,7 @@ 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.presenter.PM2VideoPresenter -import com.mogo.och.common.module.wigets.video.AdsDatas +import com.mogo.och.common.module.wigets.video.MediaDataList import com.mogo.och.common.module.wigets.video.MediaItem import kotlinx.android.synthetic.m2.p_m2_video_fragment.* @@ -55,7 +55,7 @@ class PM2VideoFragment : try { arrayListOf.clear() - var datas: AdsDatas = GsonUtils.fromJson(FunctionBuildConfig.tempConfig,object : TypeToken() {}.type) + var datas: MediaDataList = GsonUtils.fromJson(FunctionBuildConfig.tempConfig,object : TypeToken() {}.type) arrayListOf.addAll(datas.ads) } catch (e: Exception) { e.printStackTrace() diff --git a/app/config/tempConfig.json b/app/config/tempConfig.json index 6b5b6e6a76..fc00dcab9a 100644 --- a/app/config/tempConfig.json +++ b/app/config/tempConfig.json @@ -342,7 +342,7 @@ } }, "saas": { - "shuttlepassenger": { + "shuttlepassengerochjl": { "ads": [ { "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357256102/1.jpg", @@ -406,7 +406,7 @@ } ] }, - "buspassenger": { + "buspassengerochjl": { "ads": [ { "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357256102/1.jpg", @@ -470,7 +470,7 @@ } ] }, - "shuttlepassengerm2": { + "shuttlepassengerochm2": { "ads": [ { "path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1681716116231/6923474a99a1983c9a0410ad3357888d.mov", From cdbba2af3a0d819efcac670a3d62032f974ca7d7 Mon Sep 17 00:00:00 2001 From: aibingbing Date: Thu, 14 Dec 2023 19:24:48 +0800 Subject: [PATCH 03/13] =?UTF-8?q?[=E5=AE=A3=E4=BC=A0=E8=A7=86=E9=A2=91]=20?= =?UTF-8?q?refactor:=20=E5=AE=A3=E4=BC=A0=E8=A7=86=E9=A2=91=E6=92=AD?= =?UTF-8?q?=E6=94=BE=E9=87=8D=E6=9E=84=20step3=20;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bus/passenger/MogoOCHBusPassenger.java | 5 +- .../src/main/AndroidManifest.xml | 4 +- .../och/common/module/utils/FileUtils.java | 178 ++++++++ .../wigets/{video => media}/MediaBean.kt | 2 +- .../MediaDataSourceManager.kt | 6 +- .../wigets/media/MediaFileCacheManager.kt | 87 ++++ .../{video => media}/MediaLoopPlayView.kt | 18 +- .../MediaPlayerActivity.kt} | 6 +- .../wigets/media/MediaPlayerCustomView.kt | 373 +++++++++++++++++ .../MediaPlayerFragment.kt} | 14 +- .../module/wigets/video/VideoPlayerView.kt | 388 ------------------ .../main/res/layout/fragment_video_player.xml | 2 +- .../bus/passenger/MogoOCHBusPassenger.java | 4 +- .../passenger/ui/video/PM2VideoFragment.kt | 4 +- .../ui/widget/video/ImageAndVideoRotation.kt | 2 +- 15 files changed, 673 insertions(+), 420 deletions(-) create mode 100644 OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/utils/FileUtils.java rename OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/{video => media}/MediaBean.kt (90%) rename OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/{video => media}/MediaDataSourceManager.kt (98%) create mode 100644 OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaFileCacheManager.kt rename OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/{video => media}/MediaLoopPlayView.kt (95%) rename OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/{video/VideoPlayerActivity.kt => media/MediaPlayerActivity.kt} (78%) create mode 100644 OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayerCustomView.kt rename OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/{video/VideoPlayerFragment.kt => media/MediaPlayerFragment.kt} (80%) delete mode 100644 OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerView.kt 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 index cf1643aa61..c0163c5142 100644 --- 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 @@ -1,7 +1,6 @@ package com.mogo.och.bus.passenger; import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS_P; -import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_TAXI_P; import android.content.Context; @@ -17,7 +16,7 @@ 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.video.VideoPlayerActivity; +import com.mogo.och.common.module.wigets.media.MediaPlayerActivity; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -48,7 +47,7 @@ public class MogoOCHBusPassenger implements IMogoOCH { showFragment(); if (AppIdentityModeUtils.isJL(FunctionBuildConfig.appIdentityMode) && activity != null) { - MultiDisplayUtils.INSTANCE.startActWithSecond(activity, VideoPlayerActivity.class); + MultiDisplayUtils.INSTANCE.startActWithSecond(activity, MediaPlayerActivity.class); } return null; diff --git a/OCH/mogo-och-common-module/src/main/AndroidManifest.xml b/OCH/mogo-och-common-module/src/main/AndroidManifest.xml index 01f5dc90e8..c30644c2f4 100644 --- a/OCH/mogo-och-common-module/src/main/AndroidManifest.xml +++ b/OCH/mogo-och-common-module/src/main/AndroidManifest.xml @@ -3,11 +3,11 @@ 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/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/MediaBean.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaBean.kt similarity index 90% rename from OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/MediaBean.kt rename to OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaBean.kt index 25bc768391..dce6c6787a 100644 --- a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/MediaBean.kt +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaBean.kt @@ -1,4 +1,4 @@ -package com.mogo.och.common.module.wigets.video +package com.mogo.och.common.module.wigets.media data class MediaDataList(val ads: MutableList) diff --git a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/MediaDataSourceManager.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaDataSourceManager.kt similarity index 98% rename from OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/MediaDataSourceManager.kt rename to OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaDataSourceManager.kt index f893fff92b..ecfccc01e9 100644 --- a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/MediaDataSourceManager.kt +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaDataSourceManager.kt @@ -1,4 +1,4 @@ -package com.mogo.och.common.module.wigets.video +package com.mogo.och.common.module.wigets.media import android.annotation.SuppressLint import android.content.Context @@ -17,8 +17,8 @@ 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.video.MediaItem.Companion.MEDIA_TYPE_IMAGE -import com.mogo.och.common.module.wigets.video.MediaItem.Companion.MEDIA_TYPE_VIDEO +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 diff --git a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaFileCacheManager.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaFileCacheManager.kt new file mode 100644 index 0000000000..56bd0274dc --- /dev/null +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaFileCacheManager.kt @@ -0,0 +1,87 @@ +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,统一了本地缓存文件的命名,base64编码 + */ +object MediaFileCacheManager { + + const val TAG = "MediaFileCacheManager" + + /** + * 创建media缓存文件夹目录(优先放SD卡) + */ + fun createFileCacheDir(context: Context): Boolean { + val cacheDirPath = getFileCacheDir(context) + 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/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/MediaLoopPlayView.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaLoopPlayView.kt similarity index 95% rename from OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/MediaLoopPlayView.kt rename to OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaLoopPlayView.kt index 68c824818d..73f6b4eb5b 100644 --- a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/MediaLoopPlayView.kt +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaLoopPlayView.kt @@ -1,4 +1,4 @@ -package com.mogo.och.common.module.wigets.video +package com.mogo.och.common.module.wigets.media import AdvanceImageView import AdvanceVideoView @@ -13,7 +13,7 @@ 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.video.MediaLoopPlayView.Companion.IMAGE_COUNT_DOWN_SECONDS +import com.mogo.och.common.module.wigets.media.MediaLoopPlayView.Companion.IMAGE_COUNT_DOWN_SECONDS import com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack class MediaLoopPlayView @JvmOverloads constructor( @@ -140,11 +140,11 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter private fun addItemView(item: MediaItem) { if (item.isImageType()) { val imageView = AdvanceImageView(mContext) - imageView.setImagePath(item.path) + imageView.initImageUrlData(item.path) mItemViewList.add(imageView) } else if (item.isVideoType()) { val videoView = AdvanceVideoView(mContext) - videoView.setVideoPath(item.path, item.cacheImgPath) + videoView.initVideoUrlData(item.path, item.cacheImgPath) mItemViewList.add(videoView) } else { CallerLogger.d(MediaLoopPlayView.TAG, "addItemView 不支持的文件类型:${item.type}") @@ -165,13 +165,15 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter "startLoopPlay: AdvanceVideoView, url=${currentMediaItem.path}" ) val videoView = mItemViewList[currentPosition] as AdvanceVideoView - videoView.setCacheImageViewVisible() - videoView.setVideo(videoPlayLifecycleCallBack) + videoView.setThumbImageViewVisible() + videoView.startPlayVideo(videoPlayLifecycleCallBack) } else if (mItemViewList[currentPosition] is AdvanceImageView) { CallerLogger.d( MediaLoopPlayView.TAG, "startLoopPlay: AdvanceImageView, url=${currentMediaItem.path}" ) + val imageView = mItemViewList[currentPosition] as AdvanceImageView + imageView.displayImage() startImageCountDownTimer() } else { CallerLogger.d( @@ -275,7 +277,7 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter val currentPosition = mViewPager.currentItem if (mItemViewList[currentPosition] is AdvanceVideoView) { val videoView = mItemViewList[mViewPager.currentItem] as AdvanceVideoView - videoView.setPause() + videoView.setVideoPause() } else if (mItemViewList[currentPosition] is AdvanceImageView) { cancelImageCountDownTimer() } @@ -288,7 +290,7 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter val currentPosition = mViewPager.currentItem if (mItemViewList[currentPosition] is AdvanceVideoView) { val videoView = mItemViewList[mViewPager.currentItem] as AdvanceVideoView - videoView.setResume() + videoView.setVideoResume() } else if (mItemViewList[currentPosition] is AdvanceImageView) { startImageCountDownTimer() } diff --git a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerActivity.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayerActivity.kt similarity index 78% rename from OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerActivity.kt rename to OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayerActivity.kt index ee855ae81c..11e0ab9edb 100644 --- a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerActivity.kt +++ b/OCH/mogo-och-common-module/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/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayerCustomView.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayerCustomView.kt new file mode 100644 index 0000000000..8b97773683 --- /dev/null +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayerCustomView.kt @@ -0,0 +1,373 @@ +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.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.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) { + Logger.d( + MediaLoopPlayView.TAG, + "video play download, onProgress= ${(downloaded * 100 / total).toInt()}" + ) + } + + 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()) + } + } 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()) + } + } else { + startDownLoadVideoFile() + } + } + } + + override fun onError(url: String, error: String?) { + Logger.d(MediaLoopPlayView.TAG, "video play download, onError msg=$error") + //出错再次下载 + 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 + ) + Logger.d( + MediaLoopPlayView.TAG, "本地已经有缓存文件,准备开始播放,videoPath=${ + localVideoCacheFilePath + }" + ) + val realUri = Uri.fromFile(File(localVideoCacheFilePath)).toString() + setThumbImageViewGone() + startPlay(realUri) + Logger.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() + } + } + + fun setThumbImageViewVisible() { + UiThreadHandler.post { + videoPlayerView?.setCacheImageViewVisible() + } + } + + private fun setThumbImageViewGone() { + UiThreadHandler.post { + videoPlayerView?.setCacheImageViewGone() + } + } + + private fun startDownLoadVideoFile() { + //下载视频,下载成功后再播放 + Logger.d(MediaLoopPlayView.TAG, "startDownLoadVideoFile") + MediaFileCacheManager.downloadFile( + context, + videoUrl, + downListener + ) + } + + fun clearLocalErrorVideo() { + val localVideoPath = MediaFileCacheManager.getCacheFileFullPathByUrl(context, videoUrl) + if (FileUtils.isFileExists(localVideoPath)) { + FileUtils.delete(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/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerFragment.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayerFragment.kt similarity index 80% rename from OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerFragment.kt rename to OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayerFragment.kt index ba5ac18a4f..d0a81c9f48 100644 --- a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerFragment.kt +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayerFragment.kt @@ -1,7 +1,8 @@ -package com.mogo.och.common.module.wigets.video +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 @@ -12,11 +13,11 @@ import kotlinx.android.synthetic.main.fragment_video_player.imageVideoRotationVi * @author: wangmingjun * @date: 2022/4/12 */ -class VideoPlayerFragment : - MvpFragment() { +class MediaPlayerFragment : + MvpFragment() { companion object { - private val TAG = VideoPlayerFragment::class.java.simpleName + private val TAG = MediaPlayerFragment::class.java.simpleName } private var arrayListOf = mutableListOf() @@ -34,6 +35,7 @@ class VideoPlayerFragment : } override fun initViews() { + MediaFileCacheManager.createFileCacheDir(MainMoGoApplication.getApp().applicationContext) AdDataSourceManager.init(TAG, object : IAdDataSourceListener { override fun onAdDataSourceChanged(list: List) { val isNewData = arrayListOf.isNotEmpty() @@ -69,5 +71,5 @@ class VideoPlayerFragment : } } -class VideoPlayerPresenter(view: VideoPlayerFragment?) : - Presenter(view) \ No newline at end of file +class VideoPlayerPresenter(view: MediaPlayerFragment?) : + Presenter(view) \ No newline at end of file diff --git a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerView.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerView.kt deleted file mode 100644 index 520e2c2318..0000000000 --- a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerView.kt +++ /dev/null @@ -1,388 +0,0 @@ -import android.annotation.SuppressLint -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.* -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.eagle.core.widget.media.video.TextureVideoViewOutlineProvider -import com.mogo.och.common.module.R -import com.mogo.och.common.module.wigets.video.MediaLoopPlayView -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 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(MediaLoopPlayView.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(MediaLoopPlayView.TAG, "setVideo") - mOnCompletionListener = onCompletionListener - //判断是否已经下载 - if (downloadVideoName.isNotEmpty()) { - Logger.d( - MediaLoopPlayView.TAG, - "video local url = $mVideoDirPath$downloadVideoName" - ) - if (FileUtils.isFileExists(mVideoDirPath + downloadVideoName)) { - Logger.d(MediaLoopPlayView.TAG, "have cache startPlay") - startPlay(Uri.fromFile(File(mVideoDirPath + downloadVideoName)).toString()) - return - } - startDownLoadVideo() - } - } - - private fun startDownLoadVideo() { - //下载视频, 下载成功后再播放 - Logger.d(MediaLoopPlayView.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?) { - try { - Logger.d(MediaLoopPlayView.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(MediaLoopPlayView.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(MediaLoopPlayView.TAG, "download-onStart") - } - - override fun onProgress(url: String, downloaded: Long, total: Long) { - Logger.d(MediaLoopPlayView.TAG, "download-onProgress== ${ (downloaded * 100 / total).toInt() }") - } - - override fun onFinished(url: String, path: String) { - Logger.d(MediaLoopPlayView.TAG, "download-onFinished = $url") - if (url == fileNetPath) { //发现下载工具在断网又连网后,已完成的任务又都下载,跳转播放出现问题 - //下载完成 - ThreadUtils.runOnUiThread { - startPlay(Uri.fromFile(File(path)).toString()) - } - } else {//如果当前文件不存在再次去下载当前的 - Logger.d( - MediaLoopPlayView.TAG, "download-onFinished = not current" + - ",currentUrl = $fileNetPath " - ) - if (FileUtils.isFileExists(path)) { - Logger.d(MediaLoopPlayView.TAG, "have download startPlay") - ThreadUtils.runOnUiThread { - startPlay(Uri.fromFile(File(path)).toString()) - } - return - } else { - startDownLoadVideo() - } - } - } - - override fun onError(url: String, error: String?) { - Logger.d(MediaLoopPlayView.TAG, "download-onError-$error") - //出错再次下载 - startDownLoadVideo() - } - } -} - -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) - } - - 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/mogo-och-common-module/src/main/res/layout/fragment_video_player.xml b/OCH/mogo-och-common-module/src/main/res/layout/fragment_video_player.xml index 7144571ef4..8b12b3606c 100644 --- a/OCH/mogo-och-common-module/src/main/res/layout/fragment_video_player.xml +++ b/OCH/mogo-och-common-module/src/main/res/layout/fragment_video_player.xml @@ -3,7 +3,7 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - diff --git a/OCH/shuttle/passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/MogoOCHBusPassenger.java b/OCH/shuttle/passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/MogoOCHBusPassenger.java index 6848df9720..023c3f5ede 100644 --- a/OCH/shuttle/passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/MogoOCHBusPassenger.java +++ b/OCH/shuttle/passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/MogoOCHBusPassenger.java @@ -16,7 +16,7 @@ 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.video.VideoPlayerActivity; +import com.mogo.och.common.module.wigets.media.MediaPlayerActivity; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -47,7 +47,7 @@ public class MogoOCHBusPassenger implements IMogoOCH { showFragment(); if (AppIdentityModeUtils.isJL(FunctionBuildConfig.appIdentityMode)) { - MultiDisplayUtils.INSTANCE.startActWithSecond(activity, VideoPlayerActivity.class); + MultiDisplayUtils.INSTANCE.startActWithSecond(activity, MediaPlayerActivity.class); } return null; } diff --git a/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/video/PM2VideoFragment.kt b/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/video/PM2VideoFragment.kt index 26fbd734d2..68ce9ef24e 100644 --- a/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/video/PM2VideoFragment.kt +++ b/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/video/PM2VideoFragment.kt @@ -6,8 +6,8 @@ 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.presenter.PM2VideoPresenter -import com.mogo.och.common.module.wigets.video.MediaDataList -import com.mogo.och.common.module.wigets.video.MediaItem +import com.mogo.och.common.module.wigets.media.MediaDataList +import com.mogo.och.common.module.wigets.media.MediaItem import kotlinx.android.synthetic.m2.p_m2_video_fragment.* /** diff --git a/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/ImageAndVideoRotation.kt b/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/ImageAndVideoRotation.kt index 8b53b3d894..ada62648ee 100644 --- a/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/ImageAndVideoRotation.kt +++ b/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/ImageAndVideoRotation.kt @@ -4,7 +4,7 @@ import android.annotation.SuppressLint import android.content.Context import android.util.AttributeSet import android.widget.RelativeLayout -import com.mogo.och.common.module.wigets.video.MediaItem +import com.mogo.och.common.module.wigets.media.MediaItem /** * @author: wangmingjun From bb44cc3d6fef41118420ceca6ce193e2f8f930f3 Mon Sep 17 00:00:00 2001 From: aibingbing Date: Thu, 14 Dec 2023 19:26:51 +0800 Subject: [PATCH 04/13] =?UTF-8?q?[=E5=AE=A3=E4=BC=A0=E8=A7=86=E9=A2=91]=20?= =?UTF-8?q?refactor:=20=E5=AE=A3=E4=BC=A0=E8=A7=86=E9=A2=91=E6=92=AD?= =?UTF-8?q?=E6=94=BE=E9=87=8D=E6=9E=84=20step3=20;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../och/bus/passenger/ui/widget/video/AdvancePagerAdapter.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvancePagerAdapter.kt b/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvancePagerAdapter.kt index 4d1784a7c3..8f10841bf4 100644 --- a/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvancePagerAdapter.kt +++ b/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvancePagerAdapter.kt @@ -9,7 +9,7 @@ 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.MediaItem +import com.mogo.och.common.module.wigets.media.MediaItem import com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack /** From 14c6ef80290ad00cae3bde0728d53256371822fe Mon Sep 17 00:00:00 2001 From: aibingbing Date: Fri, 15 Dec 2023 16:30:22 +0800 Subject: [PATCH 05/13] =?UTF-8?q?[=E5=AE=A3=E4=BC=A0=E8=A7=86=E9=A2=91]=20?= =?UTF-8?q?refactor:=20=E5=AE=A3=E4=BC=A0=E8=A7=86=E9=A2=91=E6=92=AD?= =?UTF-8?q?=E6=94=BE=E9=87=8D=E6=9E=84=20step4,=20=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E7=B1=BB=E5=92=8C=E6=96=87=E4=BB=B6=E9=87=8D=E6=96=B0=E5=91=BD?= =?UTF-8?q?=E5=90=8D=20;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/module/wigets/media/MediaBean.kt | 16 +- .../wigets/media/MediaDataSourceManager.kt | 136 ++--- .../wigets/media/MediaFileCacheManager.kt | 2 +- .../module/wigets/media/MediaLoopPlayView.kt | 16 +- .../wigets/media/MediaPlayerFragment.kt | 14 +- .../passenger/ui/video/PM2VideoFragment.kt | 4 +- .../ui/widget/video/AdvancePagerAdapter.kt | 6 +- app/build.gradle | 17 +- app/config/MediaUrlConfig.json | 490 ++++++++++++++++++ app/config/tempConfig.json | 490 ------------------ .../mogo/launcher/startup/ConfigStartUp.kt | 4 +- .../core/data/config/FunctionBuildConfig.kt | 5 +- 12 files changed, 603 insertions(+), 597 deletions(-) create mode 100644 app/config/MediaUrlConfig.json delete mode 100644 app/config/tempConfig.json diff --git a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaBean.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaBean.kt index dce6c6787a..fc74f766a6 100644 --- a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaBean.kt +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaBean.kt @@ -1,23 +1,23 @@ package com.mogo.och.common.module.wigets.media -data class MediaDataList(val ads: MutableList) +data class MediaDataList(val medias: MutableList) data class MediaItem( - var path: String, - var type: Int, - var cacheImgPath: String, + var fileUrl: String, + var fileType: Int, + var coverImageUrl: String, var title: String ) { companion object { - const val MEDIA_TYPE_IMAGE = 0 - const val MEDIA_TYPE_VIDEO = 1 + const val MEDIA_TYPE_IMAGE = 1 + const val MEDIA_TYPE_VIDEO = 2 } fun isImageType(): Boolean { - return this.type == MEDIA_TYPE_IMAGE + return this.fileType == MEDIA_TYPE_IMAGE } fun isVideoType(): Boolean { - return this.type == MEDIA_TYPE_VIDEO + return this.fileType == MEDIA_TYPE_VIDEO } } diff --git a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaDataSourceManager.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaDataSourceManager.kt index ecfccc01e9..9a91730a4f 100644 --- a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaDataSourceManager.kt +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaDataSourceManager.kt @@ -33,21 +33,23 @@ import java.util.concurrent.ConcurrentHashMap * 2.第二优先级:使用本地数据播放 * 3.请求管理后台数据成功后:间隔10分钟再次检查 */ -object AdDataSourceManager { - private val TAG = AdDataSourceManager::class.java.simpleName +object MediaDataSourceManager { + private val TAG = MediaDataSourceManager::class.java.simpleName private const val RETRY_MAX_COUNT = 5 private var mRetryCount = 0 - private val mNetworkService: IAdNetworkApi = + private val mNetworkService: IMediaNetworkApi = MoGoRetrofitFactory.getInstance(OchCommonConst.getEagleMisUrl()) - .create(IAdNetworkApi::class.java) + .create(IMediaNetworkApi::class.java) private var driverSnCache = "" private val driverSn: String get() { + //TODO +// return "202305107384MW6" val serverToken = CallerTelematicManager.getServerToken() if (serverToken != driverSnCache && serverToken.isNotEmpty()) { driverSnCache = serverToken @@ -60,77 +62,77 @@ object AdDataSourceManager { return AbsMogoApplication.getApp() } - private val mLastAdDataSourceList = mutableListOf() + private val mLastMediaDataSourceList = mutableListOf() - private var mHasEverGetAdDataFromMis = false + private var mHasEverGetMediaDataFromMis = false - private val mAdDataSourceListenerMap: ConcurrentHashMap = + private val mMediaDataSourceListenerMap: ConcurrentHashMap = ConcurrentHashMap() private val getAdDataSourceLoopRunnable = Runnable { - startGetAdDataSourceLoop() + startGetMediaDataSourceLoop() } - fun init(tag: String, dataSourceListener: IAdDataSourceListener) { - if (!mAdDataSourceListenerMap.containsKey(tag)) { - mAdDataSourceListenerMap[tag] = dataSourceListener + fun init(tag: String, dataSourceListener: IMediaDataSourceListener) { + if (!mMediaDataSourceListenerMap.containsKey(tag)) { + mMediaDataSourceListenerMap[tag] = dataSourceListener } - startGetAdDataSourceLoop() + startGetMediaDataSourceLoop() } fun unInit(tag: String) { - removeGetAdDataSourceLoop() - if (mAdDataSourceListenerMap.containsKey(tag)) { - mAdDataSourceListenerMap.remove(tag) + removeGetMediaDataSourceLoop() + if (mMediaDataSourceListenerMap.containsKey(tag)) { + mMediaDataSourceListenerMap.remove(tag) } } @SuppressLint("MissingPermission") - private fun startGetAdDataSourceLoop() { - removeGetAdDataSourceLoop() - // 失败3次,且从来没有从MIS获取配置信息成功过,先试用本地数据播放 - if (mRetryCount == RETRY_MAX_COUNT && !mHasEverGetAdDataFromMis) { - val localAdDataList = getAdDataFromLocalConfig() - updateAdDataSource(localAdDataList) + private fun startGetMediaDataSourceLoop() { + removeGetMediaDataSourceLoop() + // 失败5次,且从来没有从MIS获取配置信息成功过,先试用本地数据播放 + if (mRetryCount == RETRY_MAX_COUNT && !mHasEverGetMediaDataFromMis) { + val localAdDataList = getMediaDataFromLocalConfig() + updateMediaDataSource(localAdDataList) CallerLogger.e(TAG, - "startGetAdDataSourceLoop:失败${mRetryCount}次,先使用本地数据播放" + "startGetMediaDataSourceLoop:失败${mRetryCount}次,先使用本地数据播放" ) } if (driverSn.isBlank()) { - CallerLogger.e(TAG, "startGetAdDataSourceLoop:司机屏sn为空,跳过本次查询" + CallerLogger.e(TAG, "startGetMediaDataSourceLoop:司机屏sn为空,跳过本次查询" ) mRetryCount++ UiThreadHandler.postDelayed(getAdDataSourceLoopRunnable, 1000L) return } if (!NetworkUtils.isConnected()) { - CallerLogger.e(TAG, "startGetAdDataSourceLoop:当前无网络,跳过本次查询" + CallerLogger.e(TAG, "startGetMediaDataSourceLoop:当前无网络,跳过本次查询" ) mRetryCount++ UiThreadHandler.postDelayed(getAdDataSourceLoopRunnable, 1000L) return } - getAdDataFromMis(object : OchCommonServiceCallback { - override fun onSuccess(data: AdDataResp?) { - mHasEverGetAdDataFromMis = true + getMediaDataFromMis(object : OchCommonServiceCallback { + override fun onSuccess(data: MediaDataResp?) { + mHasEverGetMediaDataFromMis = true CallerLogger.e(TAG, - "startGetAdDataSourceLoop:success, 从管理后台获取到数据,AdData=${ + "startGetMediaDataSourceLoop:success, 从管理后台获取到数据,AdData=${ GsonUtils.toJson( data ) }" ) - val newDataList = AdDataResp.toMediaItemList(data?.data) + val newDataList = MediaDataResp.toMediaItemList(data?.data) // 管理平台如果配置数据为空,不更新 if (newDataList.isNotEmpty()) { - if (compareAdDataSource(newDataList)) { - updateAdDataSource(newDataList) + if (compareMediaDataSource(newDataList)) { + updateMediaDataSource(newDataList) CallerLogger.e(TAG, - "startGetAdDataSourceLoop:success, 从管理后台获取到数据,更新数据" + "startGetMediaDataSourceLoop:success, 从管理后台获取到数据,更新数据" ) } else { CallerLogger.e(TAG, - "startGetAdDataSourceLoop:success, 从管理后台获取到数据,数据无变化" + "startGetMediaDataSourceLoop:success, 从管理后台获取到数据,数据无变化" ) } } @@ -140,61 +142,61 @@ object AdDataSourceManager { override fun onFail(code: Int, msg: String?) { CallerLogger.e(TAG, - "startGetAdDataSourceLoop:failed, code=$code, msg=$msg" + "startGetMediaDataSourceLoop:failed, code=$code, msg=$msg" ) mRetryCount++ - val delay = if (mHasEverGetAdDataFromMis) 5000L else 1000L + val delay = if (mHasEverGetMediaDataFromMis) 5000L else 1000L UiThreadHandler.postDelayed(getAdDataSourceLoopRunnable, delay) } override fun onError() { super.onError() - CallerLogger.e(TAG, "startGetAdDataSourceLoop:error, 网络异常" + CallerLogger.e(TAG, "startGetMediaDataSourceLoop:error, 网络异常" ) mRetryCount++ - val delay = if (mHasEverGetAdDataFromMis) 5000L else 1000L + val delay = if (mHasEverGetMediaDataFromMis) 5000L else 1000L UiThreadHandler.postDelayed(getAdDataSourceLoopRunnable, delay) } }) } - private fun removeGetAdDataSourceLoop() { + private fun removeGetMediaDataSourceLoop() { UiThreadHandler.removeCallbacks(getAdDataSourceLoopRunnable) } - private fun getAdDataFromMis(callback: OchCommonServiceCallback) { - CallerLogger.d(TAG, "getAdDataFromMis:准备发送请求,driverSn=$driverSn" + private fun getMediaDataFromMis(callback: OchCommonServiceCallback) { + CallerLogger.d(TAG, "getMediaDataFromMis:准备发送请求,driverSn=$driverSn" ) - mNetworkService.queryAdDataFromMis( + mNetworkService.queryMediaDataFromMis( sn = driverSn, screenType = "2", - ).transformTry().subscribe(OchCommonSubscribeImpl(context, callback, "getAdDataFromMis")) + ).transformTry().subscribe(OchCommonSubscribeImpl(context, callback, "getMediaDataFromMis")) } - private fun getAdDataFromLocalConfig(): List { + private fun getMediaDataFromLocalConfig(): List { val localAdDataList = mutableListOf() try { val datas: MediaDataList = GsonUtils.fromJson( - FunctionBuildConfig.tempConfig, object : TypeToken() {}.type + FunctionBuildConfig.mediaUrlConfig, object : TypeToken() {}.type ) - localAdDataList.addAll(datas.ads) + localAdDataList.addAll(datas.medias) } catch (e: Exception) { e.printStackTrace() } return localAdDataList } - private fun compareAdDataSource(newDataList: List): Boolean { - if (mLastAdDataSourceList.isEmpty() && newDataList.isNotEmpty()) { + private fun compareMediaDataSource(newDataList: List): Boolean { + if (mLastMediaDataSourceList.isEmpty() && newDataList.isNotEmpty()) { return true } - if (mLastAdDataSourceList.size != newDataList.size) { + if (mLastMediaDataSourceList.size != newDataList.size) { return true } try { newDataList.forEachIndexed { index, rotationItem -> - val oldIndexItem = mLastAdDataSourceList[index] - if (rotationItem?.path != oldIndexItem?.path) { + val oldIndexItem = mLastMediaDataSourceList[index] + if (rotationItem?.fileUrl != oldIndexItem?.fileUrl) { return true } } @@ -204,31 +206,31 @@ object AdDataSourceManager { return false } - private fun updateAdDataSource(newDataList: List) { - mLastAdDataSourceList.clear() - mLastAdDataSourceList.addAll(newDataList) - mAdDataSourceListenerMap.forEach { + private fun updateMediaDataSource(newDataList: List) { + mLastMediaDataSourceList.clear() + mLastMediaDataSourceList.addAll(newDataList) + mMediaDataSourceListenerMap.forEach { val listener = it.value - listener.onAdDataSourceChanged(newDataList) + listener.onMediaDataSourceChanged(newDataList) } } } -interface IAdDataSourceListener { - fun onAdDataSourceChanged(list: List) +interface IMediaDataSourceListener { + fun onMediaDataSourceChanged(list: List) } -interface IAdNetworkApi { +interface IMediaNetworkApi { @Headers("Content-type:application/json;charset=UTF-8") @GET("/platform/biz/adv/screen/advs") - fun queryAdDataFromMis( + fun queryMediaDataFromMis( @Query("sn") sn: String, @Query("screenType") screenType: String - ): Observable + ): Observable } -data class AdData( +data class MediaData( var id: String?, var title: String?, //素材标题 var brand: String?, @@ -239,15 +241,15 @@ data class AdData( var apply_screen: Int = 0 //应用屏幕类型: 1司机屏幕 2乘客屏 ) -data class AdDataResp(val data: List) : BaseData() { +data class MediaDataResp(val data: List) : BaseData() { companion object { - fun toMediaItemList(adDataList: List?): List { + fun toMediaItemList(mediaDataList: List?): List { val rotationItemList = mutableListOf() - adDataList?.forEach { + mediaDataList?.forEach { val rotationItem = MediaItem( - path = if (TextUtils.isEmpty(it.file_path)) "" else "${it.file_path}", - type = if (it.file_type == 1) MEDIA_TYPE_VIDEO else MEDIA_TYPE_IMAGE, - cacheImgPath = if (TextUtils.isEmpty(it.cover_path)) "" else "${it.cover_path}", + 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) diff --git a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaFileCacheManager.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaFileCacheManager.kt index 56bd0274dc..9d10106a5e 100644 --- a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaFileCacheManager.kt +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaFileCacheManager.kt @@ -13,7 +13,7 @@ import java.io.File /** * 宣传视频文件本地缓存管理类 * 1, 统一了本地缓存文件的存放目录 - * 2,统一了本地缓存文件的命名,base64编码 + * 2,统一了本地缓存文件的命名,md5编码 */ object MediaFileCacheManager { diff --git a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaLoopPlayView.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaLoopPlayView.kt index 73f6b4eb5b..922cfa01dc 100644 --- a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaLoopPlayView.kt +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaLoopPlayView.kt @@ -140,14 +140,14 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter private fun addItemView(item: MediaItem) { if (item.isImageType()) { val imageView = AdvanceImageView(mContext) - imageView.initImageUrlData(item.path) + imageView.initImageUrlData(item.fileUrl) mItemViewList.add(imageView) } else if (item.isVideoType()) { val videoView = AdvanceVideoView(mContext) - videoView.initVideoUrlData(item.path, item.cacheImgPath) + videoView.initVideoUrlData(item.fileUrl, item.coverImageUrl) mItemViewList.add(videoView) } else { - CallerLogger.d(MediaLoopPlayView.TAG, "addItemView 不支持的文件类型:${item.type}") + CallerLogger.d(MediaLoopPlayView.TAG, "addItemView 不支持的文件类型:${item.fileType}") } } @@ -162,7 +162,7 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter if (mItemViewList[currentPosition] is AdvanceVideoView) { CallerLogger.d( MediaLoopPlayView.TAG, - "startLoopPlay: AdvanceVideoView, url=${currentMediaItem.path}" + "startLoopPlay: AdvanceVideoView, url=${currentMediaItem.fileUrl}" ) val videoView = mItemViewList[currentPosition] as AdvanceVideoView videoView.setThumbImageViewVisible() @@ -170,7 +170,7 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter } else if (mItemViewList[currentPosition] is AdvanceImageView) { CallerLogger.d( MediaLoopPlayView.TAG, - "startLoopPlay: AdvanceImageView, url=${currentMediaItem.path}" + "startLoopPlay: AdvanceImageView, url=${currentMediaItem.fileUrl}" ) val imageView = mItemViewList[currentPosition] as AdvanceImageView imageView.displayImage() @@ -178,7 +178,7 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter } else { CallerLogger.d( MediaLoopPlayView.TAG, - "startLoopPlay 不支持的文件类型:${currentMediaItem.type}, url=${currentMediaItem.path}" + "startLoopPlay 不支持的文件类型:${currentMediaItem.fileType}, url=${currentMediaItem.fileUrl}" ) } } @@ -245,7 +245,7 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter val currentItemView = mItemViewList[currentPosition] CallerLogger.d( MediaLoopPlayView.TAG, - "playNextItemView, currentPosition=$currentPosition, type=${currentMediaItem.type}, url=${currentMediaItem.path}" + "playNextItemView, currentPosition=$currentPosition, type=${currentMediaItem.fileType}, url=${currentMediaItem.fileUrl}" ) if (currentItemView is AdvanceVideoView) { currentItemView.onVideoReset() @@ -254,7 +254,7 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter currentItemView.clearLocalErrorVideo() } if (mItemViewList.size == 1) { - currentItemView.startPlay(currentMediaItem.path) + currentItemView.startPlay(currentMediaItem.fileUrl) return } } diff --git a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayerFragment.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayerFragment.kt index d0a81c9f48..4e8bdfa75d 100644 --- a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayerFragment.kt +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayerFragment.kt @@ -14,7 +14,7 @@ import kotlinx.android.synthetic.main.fragment_video_player.imageVideoRotationVi * @date: 2022/4/12 */ class MediaPlayerFragment : - MvpFragment() { + MvpFragment() { companion object { private val TAG = MediaPlayerFragment::class.java.simpleName @@ -26,8 +26,8 @@ class MediaPlayerFragment : return R.layout.fragment_video_player } - override fun createPresenter(): VideoPlayerPresenter { - return VideoPlayerPresenter(this) + override fun createPresenter(): MediaPlayerPresenter { + return MediaPlayerPresenter(this) } override fun getTagName(): String { @@ -36,8 +36,8 @@ class MediaPlayerFragment : override fun initViews() { MediaFileCacheManager.createFileCacheDir(MainMoGoApplication.getApp().applicationContext) - AdDataSourceManager.init(TAG, object : IAdDataSourceListener { - override fun onAdDataSourceChanged(list: List) { + MediaDataSourceManager.init(TAG, object : IMediaDataSourceListener { + override fun onMediaDataSourceChanged(list: List) { val isNewData = arrayListOf.isNotEmpty() CallerLogger.d( TAG, "onAdDataSourceChanged:isNewData=$isNewData, list=${GsonUtils.toJson(list)}" @@ -66,10 +66,10 @@ class MediaPlayerFragment : } override fun onDestroy() { - AdDataSourceManager.unInit(TAG) + MediaDataSourceManager.unInit(TAG) super.onDestroy() } } -class VideoPlayerPresenter(view: MediaPlayerFragment?) : +class MediaPlayerPresenter(view: MediaPlayerFragment?) : Presenter(view) \ No newline at end of file diff --git a/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/video/PM2VideoFragment.kt b/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/video/PM2VideoFragment.kt index 68ce9ef24e..c42ef8645b 100644 --- a/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/video/PM2VideoFragment.kt +++ b/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/video/PM2VideoFragment.kt @@ -55,8 +55,8 @@ class PM2VideoFragment : try { arrayListOf.clear() - var datas: MediaDataList = GsonUtils.fromJson(FunctionBuildConfig.tempConfig,object : TypeToken() {}.type) - arrayListOf.addAll(datas.ads) + var datas: MediaDataList = GsonUtils.fromJson(FunctionBuildConfig.mediaUrlConfig,object : TypeToken() {}.type) + arrayListOf.addAll(datas.medias) } catch (e: Exception) { e.printStackTrace() } diff --git a/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvancePagerAdapter.kt b/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvancePagerAdapter.kt index 8f10841bf4..63dc9a15aa 100644 --- a/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvancePagerAdapter.kt +++ b/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvancePagerAdapter.kt @@ -86,13 +86,13 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter } private fun addView(item: MediaItem) { - if (item.type == 1) { // 表示视频 + if (item.fileType == 1) { // 表示视频 val videoView = AdvanceVideoView(mContext) - videoView.setVideoPath(item.path,item.cacheImgPath) + videoView.setVideoPath(item.fileUrl,item.coverImageUrl) viewList.add(videoView) } else { // 表示图片 val imageView = AdvanceImageView(mContext) - imageView.setImagePath(item.path) + imageView.setImagePath(item.fileUrl) viewList.add(imageView) } } diff --git a/app/build.gradle b/app/build.gradle index b2792e571b..8b03050831 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..70bdfb3c61 --- /dev/null +++ b/app/config/MediaUrlConfig.json @@ -0,0 +1,490 @@ +{ + "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" + } + ] + } + }, + "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" + } + ] + } + }, + "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" + } + ] + } + }, + "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" + } + ] + } + } +} diff --git a/app/config/tempConfig.json b/app/config/tempConfig.json deleted file mode 100644 index fc00dcab9a..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": { - "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" - } - ] - } - } -} 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 5345c8a129..fe245caf17 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 @@ -109,13 +109,12 @@ object FunctionBuildConfig { var appIdentityMode = "Taxi_Driver_Base" /** - * 临时配置json + * 各车型宣传视频本地配置 * 广告json - * */ @Volatile @JvmField - var tempConfig = "" + var mediaUrlConfig = "" /** From 4675d14fe84da6f59c2b90a096b94687810d4b1d Mon Sep 17 00:00:00 2001 From: aibingbing Date: Fri, 15 Dec 2023 17:42:55 +0800 Subject: [PATCH 06/13] =?UTF-8?q?[=E5=AE=A3=E4=BC=A0=E8=A7=86=E9=A2=91]=20?= =?UTF-8?q?refactor:=20=E5=AE=A3=E4=BC=A0=E8=A7=86=E9=A2=91=E6=92=AD?= =?UTF-8?q?=E6=94=BE=E9=87=8D=E6=9E=84=EF=BC=8CB2=E4=B9=98=E5=AE=A2?= =?UTF-8?q?=E5=B1=8F=E4=BD=BF=E7=94=A8common=E4=B8=AD=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=EF=BC=8C=E5=90=8C=E6=97=B6activity=E5=9B=A0=E4=B8=BA=E6=B6=89?= =?UTF-8?q?=E5=8F=8A=E7=BD=91=E7=BB=9C=E8=AF=B7=E6=B1=82=E4=B8=8D=E9=80=82?= =?UTF-8?q?=E5=90=88=E6=94=BE=E5=85=A5=E5=8D=95=E7=8B=AC=E8=BF=9B=E7=A8=8B?= =?UTF-8?q?=EF=BC=8C=E5=85=88=E6=94=BE=E5=85=A5=E4=B8=BB=E8=BF=9B=E7=A8=8B?= =?UTF-8?q?=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/AndroidManifest.xml | 1 - .../wigets/media/MediaDataSourceManager.kt | 4 +- .../passenger/presenter/PM2VideoPresenter.kt | 7 - .../och/bus/passenger/ui/PM2BaseFragment.kt | 14 +- .../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 | 48 ---- .../src/m2/res/layout/p_m2_video_fragment.xml | 13 - 12 files changed, 7 insertions(+), 815 deletions(-) delete mode 100644 OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/PM2VideoPresenter.kt delete mode 100644 OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/video/PM2VideoFragment.kt delete mode 100644 OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceGSYVideoPlayer.kt delete mode 100644 OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceImageView.kt delete mode 100644 OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvancePagerAdapter.kt delete mode 100644 OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceVideoView.kt delete mode 100644 OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceViewPager.kt delete mode 100644 OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/ImageAndVideoRotation.kt delete mode 100644 OCH/shuttle/passenger/src/m2/res/layout/p_m2_video_fragment.xml diff --git a/OCH/mogo-och-common-module/src/main/AndroidManifest.xml b/OCH/mogo-och-common-module/src/main/AndroidManifest.xml index c30644c2f4..ceb2e638c5 100644 --- a/OCH/mogo-och-common-module/src/main/AndroidManifest.xml +++ b/OCH/mogo-och-common-module/src/main/AndroidManifest.xml @@ -7,7 +7,6 @@ android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation|screenSize|smallestScreenSize" android:enabled="true" android:exported="true" - android:process=":media" android:resizeableActivity="false" android:resumeWhilePausing="true" android:screenOrientation="landscape" diff --git a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaDataSourceManager.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaDataSourceManager.kt index 9a91730a4f..a5e7af8504 100644 --- a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaDataSourceManager.kt +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaDataSourceManager.kt @@ -48,8 +48,6 @@ object MediaDataSourceManager { private val driverSn: String get() { - //TODO -// return "202305107384MW6" val serverToken = CallerTelematicManager.getServerToken() if (serverToken != driverSnCache && serverToken.isNotEmpty()) { driverSnCache = serverToken @@ -116,7 +114,7 @@ object MediaDataSourceManager { override fun onSuccess(data: MediaDataResp?) { mHasEverGetMediaDataFromMis = true CallerLogger.e(TAG, - "startGetMediaDataSourceLoop:success, 从管理后台获取到数据,AdData=${ + "startGetMediaDataSourceLoop:success, 从管理后台获取到数据,MediaData=${ GsonUtils.toJson( data ) diff --git a/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/PM2VideoPresenter.kt b/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/PM2VideoPresenter.kt deleted file mode 100644 index b62879bf4b..0000000000 --- a/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/presenter/PM2VideoPresenter.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.mogo.och.bus.passenger.presenter - -import com.mogo.commons.mvp.Presenter -import com.mogo.och.bus.passenger.ui.video.PM2VideoFragment - -class PM2VideoPresenter(view: PM2VideoFragment?) : - Presenter(view) \ No newline at end of file diff --git a/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/PM2BaseFragment.kt b/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/PM2BaseFragment.kt index bb8aaf4a23..a214921f5f 100644 --- a/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/PM2BaseFragment.kt +++ b/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/PM2BaseFragment.kt @@ -1,11 +1,9 @@ package com.mogo.och.bus.passenger.ui -import android.provider.Settings -import android.view.Surface import com.mogo.commons.mvp.MvpFragment import com.mogo.och.bus.passenger.R import com.mogo.och.bus.passenger.presenter.PM2Presenter -import com.mogo.och.bus.passenger.ui.video.PM2VideoFragment +import com.mogo.och.common.module.wigets.media.MediaPlayerFragment /** * @author: wangmingjun @@ -16,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.p_m2_fragment @@ -57,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 { @@ -67,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/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/video/PM2VideoFragment.kt b/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/video/PM2VideoFragment.kt deleted file mode 100644 index c42ef8645b..0000000000 --- a/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/video/PM2VideoFragment.kt +++ /dev/null @@ -1,64 +0,0 @@ -package com.mogo.och.bus.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.presenter.PM2VideoPresenter -import com.mogo.och.common.module.wigets.media.MediaDataList -import com.mogo.och.common.module.wigets.media.MediaItem -import kotlinx.android.synthetic.m2.p_m2_video_fragment.* - -/** - * @author: wangmingjun - * @date: 2022/4/12 - */ -class PM2VideoFragment : - MvpFragment() { - - private var arrayListOf = mutableListOf() - - override fun getLayoutId(): Int { - return R.layout.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: MediaDataList = GsonUtils.fromJson(FunctionBuildConfig.mediaUrlConfig,object : TypeToken() {}.type) - arrayListOf.addAll(datas.medias) - } catch (e: Exception) { - e.printStackTrace() - } - } -} \ No newline at end of file diff --git a/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceGSYVideoPlayer.kt b/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceGSYVideoPlayer.kt deleted file mode 100644 index 9408aba57d..0000000000 --- a/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceGSYVideoPlayer.kt +++ /dev/null @@ -1,137 +0,0 @@ -package com.mogo.och.bus.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/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceImageView.kt b/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceImageView.kt deleted file mode 100644 index cf0d030989..0000000000 --- a/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceImageView.kt +++ /dev/null @@ -1,45 +0,0 @@ -package com.mogo.och.bus.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.m2_p_video_holder) - imageView?.let { Glide.with(context).asBitmap().load(path) - .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) } - } -} \ No newline at end of file diff --git a/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvancePagerAdapter.kt b/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvancePagerAdapter.kt deleted file mode 100644 index 63dc9a15aa..0000000000 --- a/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvancePagerAdapter.kt +++ /dev/null @@ -1,211 +0,0 @@ -package com.mogo.och.bus.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.media.MediaItem -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: MediaItem) { - if (item.fileType == 1) { // 表示视频 - val videoView = AdvanceVideoView(mContext) - videoView.setVideoPath(item.fileUrl,item.coverImageUrl) - viewList.add(videoView) - } else { // 表示图片 - val imageView = AdvanceImageView(mContext) - imageView.setImagePath(item.fileUrl) - 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/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceVideoView.kt b/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceVideoView.kt deleted file mode 100644 index fdb12a594f..0000000000 --- a/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceVideoView.kt +++ /dev/null @@ -1,254 +0,0 @@ -package com.mogo.och.bus.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.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/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceViewPager.kt b/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceViewPager.kt deleted file mode 100644 index 1ec09195c3..0000000000 --- a/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/AdvanceViewPager.kt +++ /dev/null @@ -1,24 +0,0 @@ -package com.mogo.och.bus.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/m2/java/com/mogo/och/bus/passenger/ui/widget/video/ImageAndVideoRotation.kt b/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/ImageAndVideoRotation.kt deleted file mode 100644 index ada62648ee..0000000000 --- a/OCH/shuttle/passenger/src/m2/java/com/mogo/och/bus/passenger/ui/widget/video/ImageAndVideoRotation.kt +++ /dev/null @@ -1,48 +0,0 @@ -package com.mogo.och.bus.passenger.ui.widget.video - -import android.annotation.SuppressLint -import android.content.Context -import android.util.AttributeSet -import android.widget.RelativeLayout -import com.mogo.och.common.module.wigets.media.MediaItem - -/** - * @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/m2/res/layout/p_m2_video_fragment.xml b/OCH/shuttle/passenger/src/m2/res/layout/p_m2_video_fragment.xml deleted file mode 100644 index 6c82b8c9dc..0000000000 --- a/OCH/shuttle/passenger/src/m2/res/layout/p_m2_video_fragment.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - \ No newline at end of file From 2a9e9b53147c8ce766600785c817875f50d25304 Mon Sep 17 00:00:00 2001 From: aibingbing Date: Fri, 15 Dec 2023 17:45:18 +0800 Subject: [PATCH 07/13] =?UTF-8?q?[Sweeper]=20refactor:=20=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=97=A0=E7=94=A8=E6=96=87=E4=BB=B6=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/mogo/och/sweepercloud/SweeperProvider.java | 0 .../src/main/java/com/mogo/och/sweeper/SweeperProvider.java | 0 2 files changed, 0 insertions(+), 0 deletions(-) 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 diff --git a/OCH/sweeper/sweeper-cloud/src/main/java/com/mogo/och/sweepercloud/SweeperProvider.java b/OCH/sweeper/sweeper-cloud/src/main/java/com/mogo/och/sweepercloud/SweeperProvider.java deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/OCH/sweeper/sweeper/src/main/java/com/mogo/och/sweeper/SweeperProvider.java b/OCH/sweeper/sweeper/src/main/java/com/mogo/och/sweeper/SweeperProvider.java deleted file mode 100644 index e69de29bb2..0000000000 From 0871d7c9d8eb12f759a51351c7d88312f6ede903 Mon Sep 17 00:00:00 2001 From: aibingbing Date: Fri, 15 Dec 2023 20:51:31 +0800 Subject: [PATCH 08/13] =?UTF-8?q?[=E5=AE=A3=E4=BC=A0=E8=A7=86=E9=A2=91]=20?= =?UTF-8?q?refactor:=20taxi=E6=97=A0=E4=BA=BA=E5=8C=96=E4=B9=98=E5=AE=A2?= =?UTF-8?q?=E5=B1=8F=20=E5=A2=9E=E5=8A=A0=E6=95=B0=E6=8D=AE=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E5=8F=AF=E9=85=8D=E7=BD=AE=EF=BC=8C=E6=9C=AC=E6=AC=A1?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E6=95=B0=E6=8D=AE=E6=8A=BD=E5=8F=96=E5=88=B0?= =?UTF-8?q?json=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E4=B8=AD=EF=BC=8C?= =?UTF-8?q?=E5=9B=A0=E4=B8=BA=E4=B9=8B=E5=89=8Dtaxi=E9=83=BD=E6=98=AF?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E6=96=87=E4=BB=B6=E4=B8=94=E5=8F=AF=E5=85=A8?= =?UTF-8?q?=E5=B1=8F=EF=BC=8C=E6=9C=AC=E6=AC=A1=E6=96=B0=E5=A2=9E=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E5=B1=95=E7=A4=BA=E4=BD=86=E6=98=AF=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E9=99=90=E5=88=B6=E5=9B=BE=E7=89=87=E4=B8=8D=E5=8F=AF=E5=85=A8?= =?UTF-8?q?=E5=B1=8F=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wigets/media/MediaPlayerFragment.kt | 2 +- .../passenger/bean/TaxiPassengerVideoPlay.kt | 2 +- .../taxi/passenger/ui/video/InfoVideoView.kt | 110 ++++++++++------- .../ui/video/RecyclerVideoAdapter.java | 17 ++- .../passenger/widget/ConsultVideoPlayer.kt | 4 + app/config/MediaUrlConfig.json | 112 ++++++++++++++++++ 6 files changed, 202 insertions(+), 45 deletions(-) diff --git a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayerFragment.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayerFragment.kt index 4e8bdfa75d..e6b8e3fd7a 100644 --- a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayerFragment.kt +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayerFragment.kt @@ -40,7 +40,7 @@ class MediaPlayerFragment : override fun onMediaDataSourceChanged(list: List) { val isNewData = arrayListOf.isNotEmpty() CallerLogger.d( - TAG, "onAdDataSourceChanged:isNewData=$isNewData, list=${GsonUtils.toJson(list)}" + TAG, "onMediaDataSourceChanged:isNewData=$isNewData, list=${GsonUtils.toJson(list)}" ) arrayListOf.clear() arrayListOf.addAll(list) diff --git a/OCH/taxi/unmanned-passenger/src/main/java/com/mogo/och/taxi/passenger/bean/TaxiPassengerVideoPlay.kt b/OCH/taxi/unmanned-passenger/src/main/java/com/mogo/och/taxi/passenger/bean/TaxiPassengerVideoPlay.kt index a1caa20e79..d5ae6a96c6 100644 --- a/OCH/taxi/unmanned-passenger/src/main/java/com/mogo/och/taxi/passenger/bean/TaxiPassengerVideoPlay.kt +++ b/OCH/taxi/unmanned-passenger/src/main/java/com/mogo/och/taxi/passenger/bean/TaxiPassengerVideoPlay.kt @@ -1,3 +1,3 @@ package com.mogo.och.taxi.passenger.bean -class TaxiPassengerVideoPlay(var url: String, var imageUrl: String, var title: String) \ No newline at end of file +class TaxiPassengerVideoPlay(var url: String, var imageUrl: String, var title: String, var type: Int) \ No newline at end of file diff --git a/OCH/taxi/unmanned-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/video/InfoVideoView.kt b/OCH/taxi/unmanned-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/video/InfoVideoView.kt index 776188dbc4..519c3d788e 100644 --- a/OCH/taxi/unmanned-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/video/InfoVideoView.kt +++ b/OCH/taxi/unmanned-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/video/InfoVideoView.kt @@ -7,7 +7,16 @@ import android.view.LayoutInflater import android.view.View import android.widget.FrameLayout import androidx.constraintlayout.widget.ConstraintLayout +import androidx.core.view.isVisible import androidx.recyclerview.widget.RecyclerView +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.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.taxi.passenger.R import com.mogo.och.taxi.passenger.bean.TaxiPassengerVideoPlay import com.mogo.och.taxi.passenger.ui.video.layoutmanage.CarouselLayoutManager @@ -35,7 +44,7 @@ internal class InfoVideoView @JvmOverloads constructor( defStyleAttr ) { - companion object{ + companion object { private const val TAG = "VideoView" } @@ -47,35 +56,9 @@ internal class InfoVideoView @JvmOverloads constructor( private var rvVideoPlaylist: RecyclerView? = null private lateinit var indicatorView: IndicatorView private lateinit var clContain: ConstraintLayout - - private val arrayListOf by lazy { - arrayListOf().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 +66,7 @@ internal class InfoVideoView @JvmOverloads constructor( player?.let { it.exitFullScreenMode() it.onVideoPause() - if(resetVideoPlayer) { + if (resetVideoPlayer) { it.onVideoReset() } } @@ -91,12 +74,50 @@ 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() + CallerLogger.d( + TAG, + "onMediaDataSourceChanged:isNewData=$isNewData, list=${GsonUtils.toJson(list)}" + ) + val localMediaList = mutableListOf() + list.forEach { + val taxiPassengerVideoPlay = TaxiPassengerVideoPlay( + it.fileUrl, + it.coverImageUrl, + it.title, + it.fileType + ) + localMediaList.add(taxiPassengerVideoPlay) + } + if (isNewData) { + if (!isVisible) { + updateMediaListDataAndView(localMediaList) + } else { + mNewMediaList.clear() + mNewMediaList.addAll(localMediaList) + } + } else { + updateMediaListDataAndView(localMediaList) + } + } + }) + } + + private fun updateMediaListDataAndView(newList: MutableList) { + mediaList.clear() + mediaList.addAll(newList) + UiThreadHandler.post { + 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,28 @@ 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() + } + } catch (e: Exception) { + e.printStackTrace() + } } } } @@ -130,16 +162,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) @@ -193,7 +220,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,7 +246,7 @@ 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() } } @@ -227,6 +254,7 @@ internal class InfoVideoView @JvmOverloads constructor( } 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 bdf79d44b1..77bcf41e9c 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 @@ -53,17 +53,27 @@ public class RecyclerVideoAdapter extends RecyclerView.Adapter { @@ -71,6 +81,9 @@ public class RecyclerVideoAdapter extends RecyclerView.Adapter Date: Mon, 18 Dec 2023 11:52:02 +0800 Subject: [PATCH 09/13] =?UTF-8?q?[=E5=AE=A3=E4=BC=A0=E8=A7=86=E9=A2=91]=20?= =?UTF-8?q?refactor:=20T1/T2=20=E4=B9=98=E5=AE=A2=E5=B1=8F=E5=AE=A3?= =?UTF-8?q?=E4=BC=A0=E8=A7=86=E9=A2=91=20=E4=BA=A4=E4=BA=92=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/video/RecyclerVideoAdapter.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) 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 77bcf41e9c..e6622b23fe 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,12 +49,10 @@ 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.getFullscreenButton().setVisibility(isVideo ? View.VISIBLE : View.INVISIBLE); holder.gsyVideoPlayer.getStartButton().setVisibility(isVideo ? View.VISIBLE : View.INVISIBLE); holder.gsyVideoPlayer.showOrHideStartPlayButton(isVideo ? true : false); @@ -118,13 +122,11 @@ public class RecyclerVideoAdapter extends RecyclerView.Adapter Date: Mon, 18 Dec 2023 15:33:47 +0800 Subject: [PATCH 10/13] =?UTF-8?q?[=E5=AE=A3=E4=BC=A0=E8=A7=86=E9=A2=91]=20?= =?UTF-8?q?refactor:=20M1=20=E4=B9=98=E5=AE=A2=E5=B1=8F=E5=AE=A3=E4=BC=A0?= =?UTF-8?q?=E8=A7=86=E9=A2=91=20=E5=A2=9E=E5=8A=A0=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E5=8F=AF=E9=85=8D=E7=BD=AE=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E9=80=BB=E8=BE=91=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bean/TaxiPassengerVideoPlay.java | 13 +- .../passenger/ui/video/ConsultVideoPlayer.kt | 4 + .../charter/passenger/ui/video/VideoView.kt | 119 +++++++++++------- .../video/adapter/RecyclerVideoAdapter.java | 32 +++-- app/config/MediaUrlConfig.json | 112 +++++++++++++++++ 5 files changed, 226 insertions(+), 54 deletions(-) diff --git a/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/bean/TaxiPassengerVideoPlay.java b/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/bean/TaxiPassengerVideoPlay.java index dafc61f873..ab3f6db41b 100644 --- a/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/bean/TaxiPassengerVideoPlay.java +++ b/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/bean/TaxiPassengerVideoPlay.java @@ -2,16 +2,19 @@ package com.mogo.och.charter.passenger.bean; public class TaxiPassengerVideoPlay { - public TaxiPassengerVideoPlay(String url, String imageUrl, String title) { + public TaxiPassengerVideoPlay(String url, String imageUrl, String title, int type) { this.url = url; this.imageUrl = imageUrl; this.title = title; + this.type = type; } private String url; private String imageUrl; private String title; + private int type; + public String getTitle() { return title; } @@ -35,4 +38,12 @@ public class TaxiPassengerVideoPlay { public void setImageUrl(String imageUrl) { this.imageUrl = imageUrl; } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } } diff --git a/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/ui/video/ConsultVideoPlayer.kt b/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/ui/video/ConsultVideoPlayer.kt index 27f2b0b76f..166b5fc491 100644 --- a/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/ui/video/ConsultVideoPlayer.kt +++ b/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/ui/video/ConsultVideoPlayer.kt @@ -490,5 +490,9 @@ class ConsultVideoPlayer : StandardGSYVideoPlayer { fun getVideoAllCallBack(): VideoAllCallBack? { return mVideoAllCallBack } + + fun showOrHideStartPlayButton(isShow: Boolean) { + aivStartPlay?.visibility = if (isShow ) View.VISIBLE else View.GONE + } } diff --git a/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/ui/video/VideoView.kt b/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/ui/video/VideoView.kt index 8bf73eda80..6cc77986fd 100644 --- a/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/ui/video/VideoView.kt +++ b/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/ui/video/VideoView.kt @@ -5,12 +5,25 @@ import android.util.AttributeSet import android.view.LayoutInflater import android.view.View import androidx.constraintlayout.widget.ConstraintLayout +import androidx.core.view.isVisible import androidx.recyclerview.widget.RecyclerView import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener +import com.mogo.eagle.core.function.main.MainMoGoApplication import com.mogo.eagle.core.utilcode.kotlin.onClick +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.util.GsonUtils +import com.mogo.eagle.core.utilcode.util.UiThreadHandler import com.mogo.och.charter.passenger.R +import com.mogo.och.charter.passenger.bean.TaxiPassengerVideoPlay import com.mogo.och.charter.passenger.callback.IClearViewCallback import com.mogo.och.charter.passenger.ui.softcontrol.layoutmanage.CarouselLayoutManager +import com.mogo.och.charter.passenger.ui.softcontrol.layoutmanage.CarouselZoomPostLayoutListener +import com.mogo.och.charter.passenger.ui.softcontrol.layoutmanage.CenterScrollListener +import com.mogo.och.charter.passenger.ui.video.adapter.RecyclerVideoAdapter +import com.mogo.och.common.module.wigets.media.IMediaDataSourceListener +import com.mogo.och.common.module.wigets.media.MediaDataSourceManager +import com.mogo.och.common.module.wigets.media.MediaFileCacheManager +import com.mogo.och.common.module.wigets.media.MediaItem import com.shuyu.gsyvideoplayer.video.base.GSYVideoView import kotlinx.android.synthetic.main.charter_p_video_fragment.view.rvVideoPlaylist import kotlin.math.floor @@ -22,27 +35,32 @@ class VideoView @JvmOverloads constructor( ) : ConstraintLayout(context, attrs, defStyleAttr), IMoGoAutopilotStatusListener { companion object { - const val TAG = "DebugView" + const val TAG = "VideoView" } - private val arrayListOf = ArrayList() - var goneViewListener: IClearViewCallback? = null + private val mediaList = mutableListOf() + //新的数据,在view不展示的时候完成新数据更新 + private val mNewMediaList = mutableListOf() + init { LayoutInflater.from(context).inflate(R.layout.charter_p_video_fragment, this, true) onClick { goneViewListener?.goneAllView() } - initConsultData() + initView() + } + + private fun initView() { val carouselLayoutManager = - com.mogo.och.charter.passenger.ui.softcontrol.layoutmanage.CarouselLayoutManager( + CarouselLayoutManager( CarouselLayoutManager.HORIZONTAL, true ) - carouselLayoutManager.setPostLayoutListener(com.mogo.och.charter.passenger.ui.softcontrol.layoutmanage.CarouselZoomPostLayoutListener()) + carouselLayoutManager.setPostLayoutListener(CarouselZoomPostLayoutListener()) carouselLayoutManager.maxVisibleItems = 1 - rvVideoPlaylist.addOnScrollListener(object : com.mogo.och.charter.passenger.ui.softcontrol.layoutmanage.CenterScrollListener() { + rvVideoPlaylist.addOnScrollListener(object : CenterScrollListener() { var prePlayerPosition = 0 override fun pageSelect(recyclerView: RecyclerView?, newState: Int) { //播放视频 @@ -70,7 +88,6 @@ class VideoView @JvmOverloads constructor( player.onVideoPause() } } - }) carouselLayoutManager.addOnDargAutoDiffListener { adapterPosition, currentPosition -> val fl = adapterPosition - floor(adapterPosition) @@ -84,16 +101,16 @@ class VideoView @JvmOverloads constructor( } } val recyclerVideoAdapter = - com.mogo.och.charter.passenger.ui.video.adapter.RecyclerVideoAdapter( + RecyclerVideoAdapter( context, - arrayListOf, + mediaList, rvVideoPlaylist ) recyclerVideoAdapter.setOnThumbImageClilckListener { val (_, player) = getPlayer(carouselLayoutManager) if (player is ConsultVideoPlayer) { player.onVideoReset() - player.thumbImageViewLayout.visibility = View.VISIBLE + player.thumbImageViewLayout.visibility = VISIBLE } rvVideoPlaylist?.smoothScrollToPosition(it) } @@ -104,7 +121,44 @@ class VideoView @JvmOverloads constructor( override fun onAttachedToWindow() { super.onAttachedToWindow() + MediaFileCacheManager.createFileCacheDir(MainMoGoApplication.getApp().applicationContext) + MediaDataSourceManager.init(TAG, object : IMediaDataSourceListener { + override fun onMediaDataSourceChanged(list: List) { + val isNewData = mediaList.isNotEmpty() + CallerLogger.d( + TAG, + "onMediaDataSourceChanged:isNewData=$isNewData, list=${GsonUtils.toJson(list)}" + ) + val localMediaList = mutableListOf() + list.forEach { + val taxiPassengerVideoPlay = TaxiPassengerVideoPlay( + it.fileUrl, + it.coverImageUrl, + it.title, + it.fileType + ) + localMediaList.add(taxiPassengerVideoPlay) + } + if (isNewData) { + if (!isVisible) { + updateMediaListDataAndView(localMediaList) + } else { + mNewMediaList.clear() + mNewMediaList.addAll(localMediaList) + } + } else { + updateMediaListDataAndView(localMediaList) + } + } + }) + } + private fun updateMediaListDataAndView(newList: MutableList) { + mediaList.clear() + mediaList.addAll(newList) + UiThreadHandler.post { + initView() + } } private fun getPlayer(carouselLayoutManager: com.mogo.och.charter.passenger.ui.softcontrol.layoutmanage.CarouselLayoutManager): Pair { @@ -115,6 +169,7 @@ class VideoView @JvmOverloads constructor( } override fun onDetachedFromWindow() { + MediaDataSourceManager.unInit(TAG) super.onDetachedFromWindow() } @@ -133,40 +188,16 @@ class VideoView @JvmOverloads constructor( player.onVideoReset() } } + try { + // 在播放完成的时机更新整体数据 + if (mNewMediaList.isNotEmpty()) { + updateMediaListDataAndView(mNewMediaList) + mNewMediaList.clear() + } + } catch (e: Exception) { + e.printStackTrace() + } } } } - - private fun initConsultData() { - arrayListOf.clear() - arrayListOf.add( - com.mogo.och.charter.passenger.bean.TaxiPassengerVideoPlay( - "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708596763/全车型混剪增加红旗车队.m4v", - "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969511280/车队.png", - "蘑菇车联覆盖生活的方方面面" - ) - ) - arrayListOf.add( - com.mogo.och.charter.passenger.bean.TaxiPassengerVideoPlay( - "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708554279/红旗车队.m4v", - "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969553174/红旗重新排版.png", - "蘑菇车联之红旗车队" - ) - ) - arrayListOf.add( - com.mogo.och.charter.passenger.bean.TaxiPassengerVideoPlay( - "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708499497/大运会合作解说版.m4v", - "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969536177/大运会.png", - "蘑菇车联牵手成都大运会" - ) - ) - arrayListOf.add( - com.mogo.och.charter.passenger.bean.TaxiPassengerVideoPlay( - "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708409810/20210610重新排版3屏.m4v", - "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969579713/三屏.png", - "多视角体验蘑菇车联自动驾驶" - ) - ) - } - } \ No newline at end of file diff --git a/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/ui/video/adapter/RecyclerVideoAdapter.java b/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/ui/video/adapter/RecyclerVideoAdapter.java index 54978cc387..732e4ab38a 100644 --- a/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/ui/video/adapter/RecyclerVideoAdapter.java +++ b/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/ui/video/adapter/RecyclerVideoAdapter.java @@ -10,6 +10,7 @@ import androidx.recyclerview.widget.RecyclerView; import com.bumptech.glide.Glide; import com.bumptech.glide.request.RequestOptions; +import com.mogo.och.common.module.wigets.media.MediaItem; import com.mogo.och.common.module.wigets.toast.ToastCharterUtils; import com.mogo.och.charter.passenger.R; import com.mogo.och.charter.passenger.bean.TaxiPassengerVideoPlay; @@ -62,27 +63,40 @@ public class RecyclerVideoAdapter extends RecyclerView.Adapter { + if (onThumbImageClilckListener != null) { onThumbImageClilckListener.onDxChanged(holder.getAbsoluteAdapterPosition()); } - } - }); + }); + } else { + holder.gsyVideoPlayer.getThumbImageViewLayout().setOnClickListener(null); + } holder.gsyVideoPlayer.setVideoAllCallBack(new GSYSampleCallBack(){ @Override public void onAutoComplete(String url, Object... objects) { diff --git a/app/config/MediaUrlConfig.json b/app/config/MediaUrlConfig.json index fdc8233f54..79a9a68e02 100644 --- a/app/config/MediaUrlConfig.json +++ b/app/config/MediaUrlConfig.json @@ -171,6 +171,34 @@ "title": "多视角体验蘑菇车联自动驾驶" } ] + }, + "charterpassengerochm1": { + "medias": [ + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708596763/全车型混剪增加红旗车队.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969511280/车队.png", + "title": "蘑菇车联覆盖生活的方方面面" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708554279/红旗车队.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969553174/红旗重新排版.png", + "title": "蘑菇车联之红旗车队" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708499497/大运会合作解说版.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969536177/大运会.png", + "title": "蘑菇车联牵手成都大运会" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708409810/20210610重新排版3屏.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969579713/三屏.png", + "title": "多视角体验蘑菇车联自动驾驶" + } + ] } }, "dali": { @@ -345,6 +373,34 @@ "title": "多视角体验蘑菇车联自动驾驶" } ] + }, + "charterpassengerochm1": { + "medias": [ + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708596763/全车型混剪增加红旗车队.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969511280/车队.png", + "title": "蘑菇车联覆盖生活的方方面面" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708554279/红旗车队.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969553174/红旗重新排版.png", + "title": "蘑菇车联之红旗车队" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708499497/大运会合作解说版.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969536177/大运会.png", + "title": "蘑菇车联牵手成都大运会" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708409810/20210610重新排版3屏.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969579713/三屏.png", + "title": "多视角体验蘑菇车联自动驾驶" + } + ] } }, "yantai": { @@ -423,6 +479,34 @@ "title": "多视角体验蘑菇车联自动驾驶" } ] + }, + "charterpassengerochm1": { + "medias": [ + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708596763/全车型混剪增加红旗车队.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969511280/车队.png", + "title": "蘑菇车联覆盖生活的方方面面" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708554279/红旗车队.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969553174/红旗重新排版.png", + "title": "蘑菇车联之红旗车队" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708499497/大运会合作解说版.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969536177/大运会.png", + "title": "蘑菇车联牵手成都大运会" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708409810/20210610重新排版3屏.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969579713/三屏.png", + "title": "多视角体验蘑菇车联自动驾驶" + } + ] } }, "saas": { @@ -597,6 +681,34 @@ "title": "多视角体验蘑菇车联自动驾驶" } ] + }, + "charterpassengerochm1": { + "medias": [ + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708596763/全车型混剪增加红旗车队.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969511280/车队.png", + "title": "蘑菇车联覆盖生活的方方面面" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708554279/红旗车队.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969553174/红旗重新排版.png", + "title": "蘑菇车联之红旗车队" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708499497/大运会合作解说版.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969536177/大运会.png", + "title": "蘑菇车联牵手成都大运会" + }, + { + "fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708409810/20210610重新排版3屏.m4v", + "fileType": 2, + "coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969579713/三屏.png", + "title": "多视角体验蘑菇车联自动驾驶" + } + ] } } } From d0c938e58b069b05100a431722bacdb7a77f77e7 Mon Sep 17 00:00:00 2001 From: aibingbing Date: Mon, 18 Dec 2023 15:37:46 +0800 Subject: [PATCH 11/13] =?UTF-8?q?[=E5=AE=A3=E4=BC=A0=E8=A7=86=E9=A2=91]=20?= =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E4=B9=98=E5=AE=A2=E5=B1=8F=E7=89=88?= =?UTF-8?q?=E6=9C=ACV5.2.5=20;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gradle.properties b/gradle.properties index 523f8358b7..dee75f0c77 100644 --- a/gradle.properties +++ b/gradle.properties @@ -152,11 +152,11 @@ NOOP_DRIVER_VERSION=3.2.0 # 公交模式司机端版本号 BUS_DRIVER_VERSION=6.2.4 # 公交模式乘客端端版本号 -BUS_PASSENGER_VERSION=5.2.4 +BUS_PASSENGER_VERSION=5.2.5 # 接驳模式司机端版本号 SHUTTLE_DRIVER_VERSION=6.2.4 # 接驳模式乘客端端版本号 -SHUTTLE_PASSENGER_VERSION=5.2.4 +SHUTTLE_PASSENGER_VERSION=5.2.5 # 出租车模式司机端版本号 TAXI_DRIVER_VERSION=6.2.4 # 出租车模式乘客端端版本号 @@ -165,12 +165,12 @@ TAXI_PASSENGER_VERSION=5.2.4 # 出租车模式司机端版本号 TAXIUNMANNED_DRIVER_VERSION=6.2.4 # 出租车模式乘客端端版本号 -TAXIUNMANNED_PASSENGER_VERSION=5.2.4 +TAXIUNMANNED_PASSENGER_VERSION=5.2.5 # 包车模式司机端版本号 CHARTER_DRIVER_VERSION=6.2.4 # 包车模式乘客端端版本号 -CHARTER_PASSENGER_VERSION=5.2.4 +CHARTER_PASSENGER_VERSION=5.2.5 # 支持云控清扫车模式司机端版本号 SWEEPERCLOUD_DRIVER_VERSION=6.2.4 # 清扫车模式司机端版本号 From 365bd4ca2e4488e02d23c764406050f1d70524bd Mon Sep 17 00:00:00 2001 From: aibingbing Date: Mon, 18 Dec 2023 19:29:20 +0800 Subject: [PATCH 12/13] =?UTF-8?q?[=E5=AE=A3=E4=BC=A0=E8=A7=86=E9=A2=91]=20?= =?UTF-8?q?refactor:=20=E9=9D=9ESass=E7=8E=AF=E5=A2=83=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=8F=AA=E4=BB=8E=E6=9C=AC=E5=9C=B0=E8=AF=BB=E5=8F=96=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=95=B0=E6=8D=AE=EF=BC=9B=20feat:=20=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E6=95=B0=E6=8D=AE=E6=88=90=E5=8A=9F=E4=BD=86=E6=98=AF?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E4=B8=BA=E7=A9=BA=E6=97=B6=EF=BC=8C=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E6=9C=AC=E5=9C=B0=E9=85=8D=E7=BD=AE=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=EF=BC=8C=E4=BF=9D=E8=AF=81=E6=9C=89=E5=86=85=E5=AE=B9=E8=83=BD?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wigets/media/MediaDataSourceManager.kt | 58 +++++++++++++++---- 1 file changed, 48 insertions(+), 10 deletions(-) diff --git a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaDataSourceManager.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaDataSourceManager.kt index a5e7af8504..535954b1f4 100644 --- a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaDataSourceManager.kt +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaDataSourceManager.kt @@ -5,6 +5,7 @@ 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 @@ -75,7 +76,22 @@ object MediaDataSourceManager { if (!mMediaDataSourceListenerMap.containsKey(tag)) { mMediaDataSourceListenerMap[tag] = dataSourceListener } - startGetMediaDataSourceLoop() + val isSassProject = isSassProject() + CallerLogger.i( + TAG, + "init, 初始化环境 isSassProject=$isSassProject" + ) + if (isSassProject) { + startGetMediaDataSourceLoop() + } else { + CallerLogger.i( + TAG, + "init, 使用本地配置数据" + ) + //非Sass环境下后端没有实现可配置,默认只走本地配置 + val localAdDataList = getMediaDataFromLocalConfig() + updateMediaDataSource(localAdDataList) + } } fun unInit(tag: String) { @@ -85,6 +101,13 @@ object MediaDataSourceManager { } } + /** + * 是否是Sass环境 + */ + private fun isSassProject(): Boolean { + return DebugConfig.getProjectFlavor().lowercase().contains("saas") + } + @SuppressLint("MissingPermission") private fun startGetMediaDataSourceLoop() { removeGetMediaDataSourceLoop() @@ -92,19 +115,22 @@ object MediaDataSourceManager { if (mRetryCount == RETRY_MAX_COUNT && !mHasEverGetMediaDataFromMis) { val localAdDataList = getMediaDataFromLocalConfig() updateMediaDataSource(localAdDataList) - CallerLogger.e(TAG, + CallerLogger.e( + TAG, "startGetMediaDataSourceLoop:失败${mRetryCount}次,先使用本地数据播放" ) } if (driverSn.isBlank()) { - CallerLogger.e(TAG, "startGetMediaDataSourceLoop:司机屏sn为空,跳过本次查询" + CallerLogger.e( + TAG, "startGetMediaDataSourceLoop:司机屏sn为空,跳过本次查询" ) mRetryCount++ UiThreadHandler.postDelayed(getAdDataSourceLoopRunnable, 1000L) return } if (!NetworkUtils.isConnected()) { - CallerLogger.e(TAG, "startGetMediaDataSourceLoop:当前无网络,跳过本次查询" + CallerLogger.e( + TAG, "startGetMediaDataSourceLoop:当前无网络,跳过本次查询" ) mRetryCount++ UiThreadHandler.postDelayed(getAdDataSourceLoopRunnable, 1000L) @@ -113,7 +139,8 @@ object MediaDataSourceManager { getMediaDataFromMis(object : OchCommonServiceCallback { override fun onSuccess(data: MediaDataResp?) { mHasEverGetMediaDataFromMis = true - CallerLogger.e(TAG, + CallerLogger.e( + TAG, "startGetMediaDataSourceLoop:success, 从管理后台获取到数据,MediaData=${ GsonUtils.toJson( data @@ -125,21 +152,30 @@ object MediaDataSourceManager { if (newDataList.isNotEmpty()) { if (compareMediaDataSource(newDataList)) { updateMediaDataSource(newDataList) - CallerLogger.e(TAG, + CallerLogger.e( + TAG, "startGetMediaDataSourceLoop:success, 从管理后台获取到数据,更新数据" ) } else { - CallerLogger.e(TAG, + CallerLogger.e( + TAG, "startGetMediaDataSourceLoop:success, 从管理后台获取到数据,数据无变化" ) } + } else { + //请求成功获取到后台配置数据了,但是数据为空,此时为了有内容展示,还是使用本地数据更新播放 + if (mLastMediaDataSourceList.isEmpty()) { + val localAdDataList = getMediaDataFromLocalConfig() + updateMediaDataSource(localAdDataList) + } } // 获取成功后,延迟5分钟再查询 UiThreadHandler.postDelayed(getAdDataSourceLoopRunnable, 5 * 60 * 1000L) } override fun onFail(code: Int, msg: String?) { - CallerLogger.e(TAG, + CallerLogger.e( + TAG, "startGetMediaDataSourceLoop:failed, code=$code, msg=$msg" ) mRetryCount++ @@ -149,7 +185,8 @@ object MediaDataSourceManager { override fun onError() { super.onError() - CallerLogger.e(TAG, "startGetMediaDataSourceLoop:error, 网络异常" + CallerLogger.e( + TAG, "startGetMediaDataSourceLoop:error, 网络异常" ) mRetryCount++ val delay = if (mHasEverGetMediaDataFromMis) 5000L else 1000L @@ -163,7 +200,8 @@ object MediaDataSourceManager { } private fun getMediaDataFromMis(callback: OchCommonServiceCallback) { - CallerLogger.d(TAG, "getMediaDataFromMis:准备发送请求,driverSn=$driverSn" + CallerLogger.d( + TAG, "getMediaDataFromMis:准备发送请求,driverSn=$driverSn" ) mNetworkService.queryMediaDataFromMis( sn = driverSn, From add0ad88269a91a0a43d60617f561e1ec16942e1 Mon Sep 17 00:00:00 2001 From: aibingbing Date: Tue, 19 Dec 2023 15:38:13 +0800 Subject: [PATCH 13/13] =?UTF-8?q?[=E5=AE=A3=E4=BC=A0=E8=A7=86=E9=A2=91]=20?= =?UTF-8?q?feat:=20=E5=AE=A3=E4=BC=A0=E8=A7=86=E9=A2=91=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E7=9A=84=E7=BB=9F=E4=B8=80=E6=97=A5=E5=BF=97=E6=89=93=E5=8D=B0?= =?UTF-8?q?TAG=EF=BC=8C=E5=85=B3=E9=94=AE=E6=97=A5=E5=BF=97=E7=BB=9F?= =?UTF-8?q?=E4=B8=80=E4=B8=8A=E4=BC=A0=E5=A4=A7=E6=95=B0=E6=8D=AE=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../charter/passenger/ui/video/VideoView.kt | 10 +-- .../wigets/media/MediaDataSourceManager.kt | 64 +++++++------------ .../wigets/media/MediaFileCacheManager.kt | 1 + .../module/wigets/media/MediaLoopPlayView.kt | 37 +++++------ .../module/wigets/media/MediaPlayLogger.kt | 44 +++++++++++++ .../wigets/media/MediaPlayerCustomView.kt | 23 ++++--- .../taxi/passenger/ui/video/InfoVideoView.kt | 12 ++-- 7 files changed, 110 insertions(+), 81 deletions(-) create mode 100644 OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayLogger.kt 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 6cc77986fd..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 @@ -24,6 +24,7 @@ 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 @@ -80,6 +81,7 @@ class VideoView @JvmOverloads constructor( } } prePlayerPosition = centerItemPosition + MediaPlayLogger.printInfoLog("pageSelect, currentPosition=$prePlayerPosition") } override fun pageStop() { @@ -125,10 +127,7 @@ class VideoView @JvmOverloads constructor( MediaDataSourceManager.init(TAG, object : IMediaDataSourceListener { override fun onMediaDataSourceChanged(list: List) { val isNewData = mediaList.isNotEmpty() - CallerLogger.d( - TAG, - "onMediaDataSourceChanged:isNewData=$isNewData, list=${GsonUtils.toJson(list)}" - ) + MediaPlayLogger.printInfoLog("onMediaDataSourceChanged:isNewData=$isNewData, dataSize=${list.size}, list=${GsonUtils.toJson(list)}") val localMediaList = mutableListOf() list.forEach { val taxiPassengerVideoPlay = TaxiPassengerVideoPlay( @@ -142,12 +141,14 @@ class VideoView @JvmOverloads constructor( if (isNewData) { if (!isVisible) { updateMediaListDataAndView(localMediaList) + MediaPlayLogger.printInfoLog("onMediaDataSourceChanged, 宣传视频数据已更新") } else { mNewMediaList.clear() mNewMediaList.addAll(localMediaList) } } else { updateMediaListDataAndView(localMediaList) + MediaPlayLogger.printInfoLog("onMediaDataSourceChanged, 宣传视频数据已更新") } } }) @@ -193,6 +194,7 @@ class VideoView @JvmOverloads constructor( if (mNewMediaList.isNotEmpty()) { updateMediaListDataAndView(mNewMediaList) mNewMediaList.clear() + MediaPlayLogger.printInfoLog("onVisibilityChanged, 宣传视频数据已更新") } } catch (e: Exception) { e.printStackTrace() diff --git a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaDataSourceManager.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaDataSourceManager.kt index 535954b1f4..02c4b79ee9 100644 --- a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaDataSourceManager.kt +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaDataSourceManager.kt @@ -10,7 +10,6 @@ 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.mogo.logger.CallerLogger import com.mogo.eagle.core.utilcode.util.GsonUtils import com.mogo.eagle.core.utilcode.util.NetworkUtils import com.mogo.eagle.core.utilcode.util.UiThreadHandler @@ -32,7 +31,7 @@ import java.util.concurrent.ConcurrentHashMap * 如果无网络或无司机SN或请求异常 失败5次后,立马使用第二优先级本地数据播放 * 失败尝试时间间隔:1秒 * 2.第二优先级:使用本地数据播放 - * 3.请求管理后台数据成功后:间隔10分钟再次检查 + * 3.请求管理后台数据成功后:间隔5分钟再次检查 */ object MediaDataSourceManager { private val TAG = MediaDataSourceManager::class.java.simpleName @@ -77,17 +76,12 @@ object MediaDataSourceManager { mMediaDataSourceListenerMap[tag] = dataSourceListener } val isSassProject = isSassProject() - CallerLogger.i( - TAG, - "init, 初始化环境 isSassProject=$isSassProject" - ) + MediaPlayLogger.printInfoLog("init, 初始化环境 isSassProject=$isSassProject") if (isSassProject) { + MediaPlayLogger.printInfoLog("init, 开始检查后台配置数据") startGetMediaDataSourceLoop() } else { - CallerLogger.i( - TAG, - "init, 使用本地配置数据" - ) + MediaPlayLogger.printInfoLog("init, 使用本地配置数据初始化") //非Sass环境下后端没有实现可配置,默认只走本地配置 val localAdDataList = getMediaDataFromLocalConfig() updateMediaDataSource(localAdDataList) @@ -95,6 +89,7 @@ object MediaDataSourceManager { } fun unInit(tag: String) { + MediaPlayLogger.printInfoLog("unInit") removeGetMediaDataSourceLoop() if (mMediaDataSourceListenerMap.containsKey(tag)) { mMediaDataSourceListenerMap.remove(tag) @@ -110,28 +105,22 @@ object MediaDataSourceManager { @SuppressLint("MissingPermission") private fun startGetMediaDataSourceLoop() { + MediaPlayLogger.printInfoLog("startGetMediaDataSourceLoop, 开始执行后台配置数据检查") removeGetMediaDataSourceLoop() // 失败5次,且从来没有从MIS获取配置信息成功过,先试用本地数据播放 if (mRetryCount == RETRY_MAX_COUNT && !mHasEverGetMediaDataFromMis) { val localAdDataList = getMediaDataFromLocalConfig() updateMediaDataSource(localAdDataList) - CallerLogger.e( - TAG, - "startGetMediaDataSourceLoop:失败${mRetryCount}次,先使用本地数据播放" - ) + MediaPlayLogger.printErrorLog("startGetMediaDataSourceLoop:失败${mRetryCount}次,先使用本地数据播放") } if (driverSn.isBlank()) { - CallerLogger.e( - TAG, "startGetMediaDataSourceLoop:司机屏sn为空,跳过本次查询" - ) + MediaPlayLogger.printErrorLog("startGetMediaDataSourceLoop:司机屏sn为空,跳过本次查询") mRetryCount++ UiThreadHandler.postDelayed(getAdDataSourceLoopRunnable, 1000L) return } if (!NetworkUtils.isConnected()) { - CallerLogger.e( - TAG, "startGetMediaDataSourceLoop:当前无网络,跳过本次查询" - ) + MediaPlayLogger.printErrorLog("startGetMediaDataSourceLoop:当前无网络,跳过本次查询") mRetryCount++ UiThreadHandler.postDelayed(getAdDataSourceLoopRunnable, 1000L) return @@ -139,9 +128,8 @@ object MediaDataSourceManager { getMediaDataFromMis(object : OchCommonServiceCallback { override fun onSuccess(data: MediaDataResp?) { mHasEverGetMediaDataFromMis = true - CallerLogger.e( - TAG, - "startGetMediaDataSourceLoop:success, 从管理后台获取到数据,MediaData=${ + MediaPlayLogger.printInfoLog( + "startGetMediaDataSourceLoop:success, 从管理后台获取到数据,MediaSize=${data?.data?.size}, MediaData=${ GsonUtils.toJson( data ) @@ -152,45 +140,39 @@ object MediaDataSourceManager { if (newDataList.isNotEmpty()) { if (compareMediaDataSource(newDataList)) { updateMediaDataSource(newDataList) - CallerLogger.e( - TAG, - "startGetMediaDataSourceLoop:success, 从管理后台获取到数据,更新数据" - ) + MediaPlayLogger.printInfoLog("startGetMediaDataSourceLoop:success, 从管理后台获取到数据,数据有变化更新数据") } else { - CallerLogger.e( - TAG, - "startGetMediaDataSourceLoop:success, 从管理后台获取到数据,数据无变化" - ) + 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?) { - CallerLogger.e( - TAG, - "startGetMediaDataSourceLoop:failed, code=$code, msg=$msg" - ) + 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() - CallerLogger.e( - TAG, "startGetMediaDataSourceLoop:error, 网络异常" - ) + MediaPlayLogger.printErrorLog("startGetMediaDataSourceLoop:error, 网络异常") mRetryCount++ val delay = if (mHasEverGetMediaDataFromMis) 5000L else 1000L UiThreadHandler.postDelayed(getAdDataSourceLoopRunnable, delay) + MediaPlayLogger.printErrorLog("startGetMediaDataSourceLoop:error, 网络异常,延迟${delay / 1000L}秒后再次请求") } }) } @@ -200,9 +182,7 @@ object MediaDataSourceManager { } private fun getMediaDataFromMis(callback: OchCommonServiceCallback) { - CallerLogger.d( - TAG, "getMediaDataFromMis:准备发送请求,driverSn=$driverSn" - ) + MediaPlayLogger.printInfoLog("getMediaDataFromMis:准备发送请求,driverSn=$driverSn") mNetworkService.queryMediaDataFromMis( sn = driverSn, screenType = "2", @@ -219,6 +199,7 @@ object MediaDataSourceManager { } catch (e: Exception) { e.printStackTrace() } + MediaPlayLogger.printInfoLog("getMediaDataFromLocalConfig, 获取本地配置数据,dataSize=${localAdDataList.size}") return localAdDataList } @@ -249,6 +230,7 @@ object MediaDataSourceManager { val listener = it.value listener.onMediaDataSourceChanged(newDataList) } + MediaPlayLogger.printInfoLog("下发新MediaData给监听者,dataSize=${newDataList.size}") } } diff --git a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaFileCacheManager.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaFileCacheManager.kt index 9d10106a5e..259e1daaae 100644 --- a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaFileCacheManager.kt +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaFileCacheManager.kt @@ -24,6 +24,7 @@ object MediaFileCacheManager { */ fun createFileCacheDir(context: Context): Boolean { val cacheDirPath = getFileCacheDir(context) + MediaPlayLogger.printInfoLog("createFileCacheDir, dirPath=$cacheDirPath") return com.mogo.eagle.core.utilcode.util.FileUtils.createFileDir(cacheDirPath) } diff --git a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaLoopPlayView.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaLoopPlayView.kt index 922cfa01dc..af68e0398b 100644 --- a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaLoopPlayView.kt +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaLoopPlayView.kt @@ -43,7 +43,7 @@ class MediaLoopPlayView @JvmOverloads constructor( pagerAdapter?.setMediaData(list) } - fun setNewMediaData(list: MutableList){ + fun setNewMediaData(list: MutableList) { pagerAdapter?.setNewMediaData(list) } @@ -77,6 +77,7 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter private var mDataList = mutableListOf() private var mItemViewList = mutableListOf() + //新的数据,在轮播下一次切换的时机完成整体数据的更新 private val mNewDataList: MutableList = mutableListOf() @@ -85,7 +86,7 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter fun setMediaData(list: MutableList) { if (list.isEmpty()) { - CallerLogger.d(MediaLoopPlayView.TAG, "setMediaData, list为空") + MediaPlayLogger.printInfoLog( "setMediaData, list为空") return } @@ -105,7 +106,7 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter } } - fun setNewMediaData(list: MutableList){ + fun setNewMediaData(list: MutableList) { mNewDataList.clear() mNewDataList.addAll(list) } @@ -124,7 +125,6 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter } catch (e: Exception) { e.printStackTrace() } - } override fun instantiateItem(container: ViewGroup, position: Int): Any { @@ -147,7 +147,7 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter videoView.initVideoUrlData(item.fileUrl, item.coverImageUrl) mItemViewList.add(videoView) } else { - CallerLogger.d(MediaLoopPlayView.TAG, "addItemView 不支持的文件类型:${item.fileType}") + MediaPlayLogger.printErrorLog( "addItemView 不支持的文件类型:${item.fileType}") } } @@ -160,26 +160,17 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter val currentPosition = mViewPager.currentItem val currentMediaItem = mDataList[currentPosition] if (mItemViewList[currentPosition] is AdvanceVideoView) { - CallerLogger.d( - MediaLoopPlayView.TAG, - "startLoopPlay: AdvanceVideoView, url=${currentMediaItem.fileUrl}" - ) + MediaPlayLogger.printInfoLog("startLoopPlay: AdvanceVideoView, url=${currentMediaItem.fileUrl}") val videoView = mItemViewList[currentPosition] as AdvanceVideoView videoView.setThumbImageViewVisible() videoView.startPlayVideo(videoPlayLifecycleCallBack) } else if (mItemViewList[currentPosition] is AdvanceImageView) { - CallerLogger.d( - MediaLoopPlayView.TAG, - "startLoopPlay: AdvanceImageView, url=${currentMediaItem.fileUrl}" - ) + MediaPlayLogger.printInfoLog("startLoopPlay: AdvanceImageView, url=${currentMediaItem.fileUrl}") val imageView = mItemViewList[currentPosition] as AdvanceImageView imageView.displayImage() startImageCountDownTimer() } else { - CallerLogger.d( - MediaLoopPlayView.TAG, - "startLoopPlay 不支持的文件类型:${currentMediaItem.fileType}, url=${currentMediaItem.fileUrl}" - ) + MediaPlayLogger.printErrorLog("startLoopPlay 不支持的文件类型:${currentMediaItem.fileType}, url=${currentMediaItem.fileUrl}") } } @@ -215,10 +206,11 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter } override fun onFinish() { - CallerLogger.d(MediaLoopPlayView.TAG, "mImageCountDownTimer倒计时秒, onFinish") + MediaPlayLogger.printInfoLog( "mImageCountDownTimer, 倒计时${IMAGE_COUNT_DOWN_SECONDS}秒, onFinish") playNextItemView(false) } }.start() + MediaPlayLogger.printInfoLog("mImageCountDownTimer, 开始倒计时 ${IMAGE_COUNT_DOWN_SECONDS}秒") } private fun cancelImageCountDownTimer() { @@ -237,16 +229,15 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter 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] - CallerLogger.d( - MediaLoopPlayView.TAG, - "playNextItemView, currentPosition=$currentPosition, type=${currentMediaItem.fileType}, url=${currentMediaItem.fileUrl}" - ) + MediaPlayLogger.printInfoLog("playNextItemView, currentPosition=$currentPosition, type=${currentMediaItem.fileType}, url=${currentMediaItem.fileUrl}") if (currentItemView is AdvanceVideoView) { currentItemView.onVideoReset() //videoView.setCacheImageViewVisible() @@ -271,6 +262,7 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter } fun setPause() { + MediaPlayLogger.printInfoLog("${MediaLoopPlayView.TAG}, setPause") if (mItemViewList.size <= 0) { return } @@ -284,6 +276,7 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter } fun setResume() { + MediaPlayLogger.printInfoLog("${MediaLoopPlayView.TAG}, setResume") if (mItemViewList.size <= 0) { return } diff --git a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayLogger.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayLogger.kt new file mode 100644 index 0000000000..2fdb2c88c9 --- /dev/null +++ b/OCH/mogo-och-common-module/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/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayerCustomView.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayerCustomView.kt index 8b97773683..247966aac8 100644 --- a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayerCustomView.kt +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/media/MediaPlayerCustomView.kt @@ -7,6 +7,7 @@ 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 @@ -15,6 +16,7 @@ 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 @@ -43,10 +45,14 @@ class AdvanceVideoView @JvmOverloads constructor( } override fun onProgress(url: String, downloaded: Long, total: Long) { + val percent = (downloaded * 100 / total).toInt() Logger.d( MediaLoopPlayView.TAG, - "video play download, onProgress= ${(downloaded * 100 / total).toInt()}" + "video play download, onProgress= ${percent}" ) + if (percent % 10 == 0) { + MediaPlayLogger.printInfoLog("downListener,percent=$percent, downloadUrl=${videoUrl}") + } } override fun onFinished(url: String, path: String) { @@ -57,6 +63,7 @@ class AdvanceVideoView @JvmOverloads constructor( ThreadUtils.runOnUiThread { startPlay(Uri.fromFile(File(path)).toString()) } + MediaPlayLogger.printInfoLog("download finished, 开始播放,downloadUrl=${videoUrl}") } else {//如果当前文件不存在再次去下载当前的 Logger.d( MediaLoopPlayView.TAG, @@ -67,6 +74,7 @@ class AdvanceVideoView @JvmOverloads constructor( ThreadUtils.runOnUiThread { startPlay(Uri.fromFile(File(path)).toString()) } + MediaPlayLogger.printInfoLog("download finished, 开始播放,downloadUrl=${videoUrl}") } else { startDownLoadVideoFile() } @@ -75,6 +83,7 @@ class AdvanceVideoView @JvmOverloads constructor( override fun onError(url: String, error: String?) { Logger.d(MediaLoopPlayView.TAG, "video play download, onError msg=$error") + MediaPlayLogger.printErrorLog("download error, 准备重新下载,downloadUrl=${videoUrl}") //出错再次下载 startDownLoadVideoFile() } @@ -127,15 +136,11 @@ class AdvanceVideoView @JvmOverloads constructor( val localVideoCacheFilePath = MediaFileCacheManager.getCacheFileFullPathByUrl( context, this.videoUrl ) - Logger.d( - MediaLoopPlayView.TAG, "本地已经有缓存文件,准备开始播放,videoPath=${ - localVideoCacheFilePath - }" - ) + MediaPlayLogger.printInfoLog("本地已经有缓存文件,准备开始播放,videoPath=${localVideoCacheFilePath}") val realUri = Uri.fromFile(File(localVideoCacheFilePath)).toString() setThumbImageViewGone() startPlay(realUri) - Logger.d( + CallerLogger.d( MediaLoopPlayView.TAG, "播放视频,videoUri=$realUri" ) } else { @@ -155,6 +160,7 @@ class AdvanceVideoView @JvmOverloads constructor( setThumbImageViewVisible() startDownLoadVideoFile() + MediaPlayLogger.printInfoLog("本地无缓存文件,准备下载,downloadUrl=${this.videoUrl}") } } @@ -172,7 +178,7 @@ class AdvanceVideoView @JvmOverloads constructor( private fun startDownLoadVideoFile() { //下载视频,下载成功后再播放 - Logger.d(MediaLoopPlayView.TAG, "startDownLoadVideoFile") + MediaPlayLogger.printInfoLog( "startDownLoadVideoFile, downloadUrl=${this.videoUrl}") MediaFileCacheManager.downloadFile( context, videoUrl, @@ -185,6 +191,7 @@ class AdvanceVideoView @JvmOverloads constructor( if (FileUtils.isFileExists(localVideoPath)) { FileUtils.delete(localVideoPath) } + MediaPlayLogger.printInfoLog( "clearLocalErrorVideo, localPath=${localVideoPath}") } fun startPlay(localVideoPath: String?) { diff --git a/OCH/taxi/unmanned-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/video/InfoVideoView.kt b/OCH/taxi/unmanned-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/video/InfoVideoView.kt index 519c3d788e..33cf797af8 100644 --- a/OCH/taxi/unmanned-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/video/InfoVideoView.kt +++ b/OCH/taxi/unmanned-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/video/InfoVideoView.kt @@ -17,6 +17,7 @@ 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.mogo.och.taxi.passenger.R import com.mogo.och.taxi.passenger.bean.TaxiPassengerVideoPlay import com.mogo.och.taxi.passenger.ui.video.layoutmanage.CarouselLayoutManager @@ -79,10 +80,7 @@ internal class InfoVideoView @JvmOverloads constructor( MediaDataSourceManager.init(TAG, object : IMediaDataSourceListener { override fun onMediaDataSourceChanged(list: List) { val isNewData = mediaList.isNotEmpty() - CallerLogger.d( - TAG, - "onMediaDataSourceChanged:isNewData=$isNewData, list=${GsonUtils.toJson(list)}" - ) + MediaPlayLogger.printInfoLog("onMediaDataSourceChanged:isNewData=$isNewData, dataSize=${list.size}, list=${GsonUtils.toJson(list)}") val localMediaList = mutableListOf() list.forEach { val taxiPassengerVideoPlay = TaxiPassengerVideoPlay( @@ -96,12 +94,14 @@ internal class InfoVideoView @JvmOverloads constructor( if (isNewData) { if (!isVisible) { updateMediaListDataAndView(localMediaList) + MediaPlayLogger.printInfoLog("onMediaDataSourceChanged, 宣传视频数据已更新") } else { mNewMediaList.clear() mNewMediaList.addAll(localMediaList) } } else { updateMediaListDataAndView(localMediaList) + MediaPlayLogger.printInfoLog("onMediaDataSourceChanged, 宣传视频数据已更新") } } }) @@ -148,6 +148,7 @@ internal class InfoVideoView @JvmOverloads constructor( if (mNewMediaList.isNotEmpty()) { updateMediaListDataAndView(mNewMediaList) mNewMediaList.clear() + MediaPlayLogger.printInfoLog("onVisibilityChanged, 宣传视频数据已更新") } } catch (e: Exception) { e.printStackTrace() @@ -198,6 +199,7 @@ internal class InfoVideoView @JvmOverloads constructor( } } prePlayerPosition = centerItemPosition + MediaPlayLogger.printInfoLog("pageSelect, currentPosition=$prePlayerPosition") } override fun pageStop() { @@ -206,7 +208,6 @@ internal class InfoVideoView @JvmOverloads constructor( player.onVideoPause() } } - }) carouselLayoutManager.addOnDargAutoDiffListener { adapterPosition, currentPosition -> val fl = adapterPosition - floor(adapterPosition) @@ -250,7 +251,6 @@ internal class InfoVideoView @JvmOverloads constructor( player.onVideoPause() } } - } override fun onDetachedFromWindow() {