diff --git a/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/MogoOCHBusPassenger.java b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/MogoOCHBusPassenger.java index 4eca36933e..1598873f2c 100644 --- a/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/MogoOCHBusPassenger.java +++ b/OCH/mogo-och-bus-passenger/src/jinlvvan/java/com/mogo/och/bus/passenger/MogoOCHBusPassenger.java @@ -3,15 +3,20 @@ package com.mogo.och.bus.passenger; import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_TAXI_P; import android.content.Context; +import android.content.Intent; +import android.util.Log; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; import com.alibaba.android.arouter.facade.annotation.Route; +import com.mogo.eagle.core.data.config.FunctionBuildConfig; import com.mogo.eagle.core.function.call.setting.CallerMoGoUiSettingManager; +import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; import com.mogo.och.bus.passenger.constant.BusPassengerConst; import com.mogo.och.bus.passenger.ui.BusPassengerRouteFragment; +import com.mogo.och.common.module.wigets.video.VideoPlayerActivity; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -40,6 +45,11 @@ public class MogoOCHBusPassenger implements IMogoOCH { this.mActivity = activity; this.mContainerId = containerId; showFragment(); + Log.d(TAG, "MogoOCHBusPassenger-init"); + if (AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode) + && AppIdentityModeUtils.isJL(FunctionBuildConfig.appIdentityMode)) { + activity.startActivity(new Intent(activity, VideoPlayerActivity.class)); + } return null; } diff --git a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/BusPassengerM2.kt b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/BusPassengerM2.kt index 2fdb5c96b0..2fa5cd6d09 100644 --- a/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/BusPassengerM2.kt +++ b/OCH/mogo-och-bus-passenger/src/m2/java/com/mogo/och/bus/passenger/BusPassengerM2.kt @@ -4,9 +4,6 @@ import android.content.Context import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentActivity import com.alibaba.android.arouter.facade.annotation.Route -import com.mogo.commons.module.status.IMogoStatusChangedListener -import com.mogo.commons.module.status.MogoStatusManager -import com.mogo.commons.module.status.StatusDescriptor import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager.getMapUIController import com.mogo.eagle.core.function.call.setting.CallerMoGoUiSettingManager.stepInDayMode import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d diff --git a/OCH/mogo-och-common-module/src/main/AndroidManifest.xml b/OCH/mogo-och-common-module/src/main/AndroidManifest.xml index fad19aeea9..01f5dc90e8 100644 --- a/OCH/mogo-och-common-module/src/main/AndroidManifest.xml +++ b/OCH/mogo-och-common-module/src/main/AndroidManifest.xml @@ -1,5 +1,18 @@ - / + + + \ No newline at end of file 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 new file mode 100644 index 0000000000..6457ffd54b --- /dev/null +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/ImageVideoRotationView.kt @@ -0,0 +1,45 @@ +package com.mogo.och.common.module.wigets.video + +import AdvancePagerAdapter +import AdvanceViewPager +import RotationItem +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/VideoPlayerActivity.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerActivity.kt new file mode 100644 index 0000000000..76fb4caa92 --- /dev/null +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerActivity.kt @@ -0,0 +1,7 @@ +package com.mogo.och.common.module.wigets.video + +import androidx.appcompat.app.AppCompatActivity + +class VideoPlayerActivity : AppCompatActivity() { + +} \ 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 new file mode 100644 index 0000000000..f1a759a353 --- /dev/null +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerFragment.kt @@ -0,0 +1,135 @@ +package com.mogo.och.common.module.wigets.video + +import RotationItem +import com.mogo.commons.mvp.MvpFragment +import com.mogo.commons.mvp.Presenter +import com.mogo.och.common.module.R +import kotlinx.android.synthetic.main.fragment_video_player.* + +/** + * @author: wangmingjun + * @date: 2022/4/12 + */ +class VideoPlayerFragment : + MvpFragment() { + + private var arrayListOf = mutableListOf() + + override fun getLayoutId(): Int { + return R.layout.fragment_video_player + } + + override fun createPresenter(): VideoPlayerPresenter { + return VideoPlayerPresenter(this) + } + + companion object { + private val TAG = VideoPlayerFragment::class.java.simpleName + } + + override fun getTagName(): String { + return TAG + } + + override fun initViews() { + initResourceData() + imageVideoRotationView.setData(arrayListOf) + } + + override fun onPause() { + super.onPause() + imageVideoRotationView.setPause() + } + + override fun onResume() { + super.onResume() + imageVideoRotationView.setResume() + } + + private fun initResourceData() { + arrayListOf.clear() + arrayListOf.add( + RotationItem( + "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357256102/1.jpg", + 0, + "", + "1" + ) + ) + arrayListOf.add( + RotationItem( + "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png", + 0, + "", + "2" + ) + ) + arrayListOf.add( + RotationItem( + "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357557335/3.mp4", + 1, + "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png", + "3" + ) + ) + arrayListOf.add( + RotationItem( + "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", + 0, + "", + "4" + ) + ) + arrayListOf.add( + RotationItem( + "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357834634/5.m4v", + 1, + "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", + "5" + ) + ) + arrayListOf.add( + RotationItem( + "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676358660379/6.m4v", + 1, + "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg", + "6" + ) + ) + arrayListOf.add( + RotationItem( + "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360154589/7.jpg", + 0, + "", + "7" + ) + ) + arrayListOf.add( + RotationItem( + "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360185500/8.jpg", + 0, + "", + "8" + ) + ) + arrayListOf.add( + RotationItem( + "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png", + 0, + "", + "9" + ) + ) + arrayListOf.add( + RotationItem( + "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360274126/10.mp4", + 1, + "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png", + "10" + ) + ) + } +} + +class VideoPlayerPresenter(view: VideoPlayerFragment?) : + 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 new file mode 100644 index 0000000000..5cdc31da61 --- /dev/null +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/video/VideoPlayerView.kt @@ -0,0 +1,547 @@ +import android.annotation.SuppressLint +import android.content.Context +import android.media.AudioManager +import android.net.Uri +import android.util.AttributeSet +import android.view.MotionEvent +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.RelativeLayout +import androidx.viewpager.widget.PagerAdapter +import androidx.viewpager.widget.ViewPager +import com.bumptech.glide.Glide +import com.bumptech.glide.request.RequestOptions +import com.mogo.eagle.core.utilcode.breakpoint.bean.ThreadBean +import com.mogo.eagle.core.utilcode.breakpoint.callback.IDownload +import com.mogo.eagle.core.utilcode.breakpoint.utils.DownloadUtils +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.och.common.module.R +import com.mogo.och.common.module.wigets.video.ImageVideoRotationView +import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder +import com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack +import com.shuyu.gsyvideoplayer.utils.Debuger +import com.shuyu.gsyvideoplayer.utils.GSYVideoType +import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer +import java.io.File +import java.lang.Exception + +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] + } + loadCacheImg() + } + + private fun loadCacheImg() { + cacheImage?.setImageResource(R.drawable.video_holder) + setCacheImageViewVisible() + } + + fun clearLocalErrorVideo() { + if (downloadVideoName.isNotEmpty() + && FileUtils.isFileExists(mVideoDirPath + downloadVideoName) + ) { + FileUtils.delete(mVideoDirPath + downloadVideoName) + } + } + + @SuppressLint("CheckResult") + fun setCacheImageViewVisible() { + videoViewPlayer?.thumbImageView = cacheImage + videoViewPlayer?.setCacheImageViewVisible() + } + + fun setCacheImageViewGone() { + videoViewPlayer?.setCacheImageViewGone() + videoViewPlayer?.clearThumbImageView() + } + + fun setVideo(onCompletionListener: GSYSampleCallBack) { + Logger.d(ImageVideoRotationView.TAG, "setVideo") + mOnCompletionListener = onCompletionListener + //判断是否已经下载 + if (downloadVideoName.isNotEmpty()) { + Logger.d( + ImageVideoRotationView.TAG, + "video local url = $mVideoDirPath$downloadVideoName" + ) + if (FileUtils.isFileExists(mVideoDirPath + downloadVideoName)) { + Logger.d(ImageVideoRotationView.TAG, "have cache startPlay") + startPlay() + return + } + startDownLoadVideo() + } + } + + private fun startDownLoadVideo() { + //下载视频, 下载成功后再播放 + Logger.d(ImageVideoRotationView.TAG, "startDownLoadVideo") + FileUtils.createFileDir(mVideoDirPath) + DownloadUtils.downLoad( + context, fileNetPath, mVideoDirPath, downloadVideoName, 5, downListener + ) + } + + private fun startPlay() { + try { + Logger.d(ImageVideoRotationView.TAG, "startPlay") + gsyVideoOptionBuilder = GSYVideoOptionBuilder() + gsyVideoOptionBuilder + ?.setUrl( + Uri.fromFile(File(mVideoDirPath + downloadVideoName)).toString() + ) // "/data/user/0/com.mogo.launcher.f/files/video/" + ?.setPlayTag(downloadVideoName) + ?.setCacheWithPlay(false) + ?.setThumbPlay(false) + ?.build(videoViewPlayer) + + videoViewPlayer?.isFocusableInTouchMode = false + videoViewPlayer?.setVideoAllCallBack(mOnCompletionListener) + videoViewPlayer?.startPlayLogic() + } catch (e: Exception) { + Logger.d(ImageVideoRotationView.TAG, "startPlay e = ${e.message}") + } + } + + fun onVideoReset() { + videoViewPlayer?.onVideoReset() + mOnCompletionListener = null + } + + fun setPause() { + if (videoViewPlayer !== null) { + videoViewPlayer?.onVideoPause() + } + } + + fun setResume() { + if (videoViewPlayer !== null) { + videoViewPlayer?.onVideoResume() + } + } + + private val downListener = object : IDownload { + override fun onStart(url: String?) { + Logger.d(ImageVideoRotationView.TAG, "download-onStart") + } + + override fun onPause(url: String?, threadBean: ThreadBean?) { + Logger.d(ImageVideoRotationView.TAG, "download-onPause") + } + + override fun onProgress(url: String?, length: Int) { + Logger.d(ImageVideoRotationView.TAG, "download-onProgress== $length") + } + + override fun onFinished(url: String?, threadBean: ThreadBean?) { + Logger.d(ImageVideoRotationView.TAG, "download-onFinished") + //下载完成 + ThreadUtils.runOnUiThread { + startPlay() + } + } + + override fun onError(url: String?, errorMsg: String?) { + Logger.d(ImageVideoRotationView.TAG, "download-onError-$errorMsg") + //出错再次下载 + if (errorMsg != null) { + if (errorMsg.startsWith("initFailed")) { + 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) + videoView.setCacheImageViewGone() + } + } + + 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() + videoView.setCacheImageViewVisible() + 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) + } + } + } +} + +data class RotationItem( + var path: String, + var type: Int, + var cacheImgPath: String, + var title: String +) + +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?.let { + Glide.with(context).load(path) + .apply(RequestOptions().placeholder(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() { + hideWidget() + } + + override fun changeUiToNormal() { + Debuger.printfLog("changeUiToNormal") + hideWidget() + } + + override fun changeUiToPreparingShow() { + hideWidget() + } + + override fun changeUiToPlayingShow() { + hideWidget() + } + + override fun changeUiToPauseShow() { + hideWidget() + } + + override fun changeUiToCompleteShow() { + hideWidget() + } + + override fun changeUiToPlayingBufferingShow() { + 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(mTopContainer, INVISIBLE) + + setViewShowState(mLoadingProgressBar, INVISIBLE) + setViewShowState( + mLockScreen, INVISIBLE + ) + + setIsTouchWiget(false) + isFocusableInTouchMode = false + } + + fun setCacheImageViewVisible() { + if (mThumbImageViewLayout.visibility == INVISIBLE) { + setViewShowState(mThumbImageViewLayout, VISIBLE) + setViewShowState(mThumbImageView, VISIBLE) + } + } + + fun setCacheImageViewGone() { + if (mThumbImageViewLayout.visibility == VISIBLE) { + setViewShowState(mThumbImageViewLayout, INVISIBLE) + setViewShowState(mThumbImageView, INVISIBLE) + } + } + + //失去焦点声音压低 + override fun onLossTransientCanDuck() { + setNeedMute(true) + } + + //获取焦点声音恢复 + override fun onGankAudio() { + setNeedMute(false) + } + + private fun setStreamVolume(percent: Float) { + var mAudioManager = mContext?.getSystemService(Context.AUDIO_SERVICE) as AudioManager + var maxVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC) + var volume = (percent * maxVolume).toInt() + if (volume < 0) { + volume = 0 + } + mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, volume, 0) + } + + private fun setNeedMute(isMute: Boolean) { + gsyVideoManager?.player?.setNeedMute(isMute) + } +} \ No newline at end of file diff --git a/OCH/mogo-och-common-module/src/main/res/drawable-nodpi/video_holder.png b/OCH/mogo-och-common-module/src/main/res/drawable-nodpi/video_holder.png new file mode 100644 index 0000000000..99bfcefc6f Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable-nodpi/video_holder.png differ diff --git a/OCH/mogo-och-common-module/src/main/res/layout/activity_video_player.xml b/OCH/mogo-och-common-module/src/main/res/layout/activity_video_player.xml new file mode 100644 index 0000000000..fed57e72e9 --- /dev/null +++ b/OCH/mogo-och-common-module/src/main/res/layout/activity_video_player.xml @@ -0,0 +1,13 @@ + + + + + + \ 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 new file mode 100644 index 0000000000..44c0c0702f --- /dev/null +++ b/OCH/mogo-och-common-module/src/main/res/layout/fragment_video_player.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainLauncherActivity.java b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainLauncherActivity.java index 87fc4118c7..5c5fc11650 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainLauncherActivity.java +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainLauncherActivity.java @@ -125,14 +125,13 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis } } else { // 目前只有金旅星辰乘客屏是连接的双屏 - if (AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode) - && AppIdentityModeUtils.isJL(FunctionBuildConfig.appIdentityMode)) { + if (AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) { ochProvider = (IMoGoFunctionProvider) ARouter.getInstance() .build("/passenger/api") .navigation(getContext()); - MultiDisplayUtils.INSTANCE.startActWithSecond( - this, - VideoAdAtc.class); +// MultiDisplayUtils.INSTANCE.startActWithSecond( +// this, +// VideoAdAtc.class); } else { ochProvider = (IMoGoFunctionProvider) ARouter.getInstance() .build("/noop/api")