diff --git a/app/src/main/java/com/gh/gamecenter/gamedetail/video/TopVideoView.kt b/app/src/main/java/com/gh/gamecenter/gamedetail/video/TopVideoView.kt index 4becd40f3f..7c158c07cf 100644 --- a/app/src/main/java/com/gh/gamecenter/gamedetail/video/TopVideoView.kt +++ b/app/src/main/java/com/gh/gamecenter/gamedetail/video/TopVideoView.kt @@ -2,7 +2,6 @@ package com.gh.gamecenter.gamedetail.video import android.content.Context import android.os.Handler -import android.preference.PreferenceManager import android.util.AttributeSet import android.view.GestureDetector import android.view.MotionEvent @@ -18,11 +17,11 @@ import com.gh.common.observer.VolumeObserver import com.gh.common.util.MtaHelper import com.gh.common.util.SPUtils import com.gh.common.util.StringUtils +import com.gh.common.util.debounceActionWithInterval import com.gh.download.DownloadManager import com.gh.gamecenter.R import com.gh.gamecenter.entity.GameDetailEntity import com.gh.gamecenter.gamedetail.GameDetailViewModel -import com.halo.assistant.fragment.SettingsFragment import com.lightgame.utils.Utils import com.shuyu.gsyvideoplayer.GSYVideoManager import com.shuyu.gsyvideoplayer.utils.CommonUtil @@ -88,13 +87,15 @@ class TopVideoView @JvmOverloads constructor(context: Context, attrs: AttributeS } errorBtn.setOnClickListener { - if (!NetworkUtils.isAvailable(mContext)) { - Utils.toast(context, "网络异常,请检查手机网络状态") - setViewShowState(mStartButton, View.INVISIBLE) - errorContainer.visibility = View.VISIBLE - return@setOnClickListener + debounceActionWithInterval(errorBtn.id, 1000) { + if (!NetworkUtils.isAvailable(mContext)) { + Utils.toast(context, "网络异常,请检查手机网络状态") + setViewShowState(mStartButton, View.INVISIBLE) + errorContainer.visibility = View.VISIBLE + return@debounceActionWithInterval + } + startPlayLogic(false) } - startPlayLogic(false) } } diff --git a/app/src/main/java/com/gh/gamecenter/video/detail/DetailPlayerView.kt b/app/src/main/java/com/gh/gamecenter/video/detail/DetailPlayerView.kt index b3ddf059bd..7c432d5a50 100644 --- a/app/src/main/java/com/gh/gamecenter/video/detail/DetailPlayerView.kt +++ b/app/src/main/java/com/gh/gamecenter/video/detail/DetailPlayerView.kt @@ -315,6 +315,7 @@ class DetailPlayerView @JvmOverloads constructor(context: Context, attrs: Attrib //添加动画View,播放点赞动画 private fun playLikeAnimation() { + removeLikeAnimation() mLottieLike = LottieAnimationView(context) mLottieLike?.setAnimation("lottie/like.json") val location = IntArray(2) @@ -340,6 +341,7 @@ class DetailPlayerView @JvmOverloads constructor(context: Context, attrs: Attrib if (mLottieLike != null) { likeIv.visibility = View.VISIBLE likeView.removeView(mLottieLike) + mLottieLike = null } } @@ -349,11 +351,10 @@ class DetailPlayerView @JvmOverloads constructor(context: Context, attrs: Attrib if (mNetSate != state) { Debuger.printfError("******* change network state ******* $state") mNetChanged = true - - if (errorContainer.visibility == View.VISIBLE && "NONE" != state) { - seekOnStart = currentPositionWhenPlaying.toLong() - startPlayLogic() - } + } + if (errorContainer.visibility == View.VISIBLE && "NONE" != state) { + seekOnStart = currentPositionWhenPlaying.toLong() + startPlayLogic() } mNetSate = state }) @@ -452,6 +453,9 @@ class DetailPlayerView @JvmOverloads constructor(context: Context, attrs: Attrib setViewShowState(mBottomProgressBar, View.VISIBLE) setViewShowState(mBottomContainer, View.GONE) errorContainer.visibility = View.GONE + //不提前监听网络,会造成视频一开始加载失败无法重连 + createNetWorkState() + listenerNetWorkState() AppExecutor.uiExecutor.executeWithDelay(Runnable { if (mCurrentState == CURRENT_STATE_PREPAREING) { @@ -503,6 +507,7 @@ class DetailPlayerView @JvmOverloads constructor(context: Context, attrs: Attrib setViewShowState(mBottomProgressBar, if (isBottomContainerShow) View.GONE else View.VISIBLE) setViewShowState(mBottomContainer, if (isBottomContainerShow) View.VISIBLE else View.GONE) errorContainer.visibility = View.GONE + removeLikeAnimation() } override fun changeUiToPlayingBufferingShow() { @@ -641,6 +646,7 @@ class DetailPlayerView @JvmOverloads constructor(context: Context, attrs: Attrib gsyVideoManager.pause() Utils.toast(context, "网络错误,视频播放失败") setViewShowState(mStartButton, View.INVISIBLE) + setViewShowState(mLoadingProgressBar, View.GONE) errorContainer.visibility = View.VISIBLE }