Merge branch 'fix/splash_video_flick' into 'dev'

fix: 处理启动时的广告视频图片闪烁问题

See merge request halo/android/assistant-android!1824
This commit is contained in:
陈君陶
2024-08-09 14:24:39 +08:00
4 changed files with 33 additions and 25 deletions

View File

@ -543,15 +543,14 @@ object AdDelegateHelper {
), null, null
)
adImage.visibleIf(true)
ImageUtils.display(adImage, ad.img)
if (ad.isImageType) {
adImage.visibleIf(true)
adVideo.visibleIf(false)
ImageUtils.display(adImage, ad.img)
} else {
adImage.visibleIf(false)
adVideo.visibleIf(true)
adVideo.startPlay(ad.img, ad.video.url)
adVideo.startPlay(ad.video.url)
}
startAdContainer.setOnClickListener {
// 拦截点击事件传递

View File

@ -1,12 +1,11 @@
package com.gh.ad
import android.app.Activity
import android.content.Context
import android.util.AttributeSet
import com.facebook.drawee.view.SimpleDraweeView
import android.view.WindowManager
import com.gh.gamecenter.R
import com.gh.gamecenter.common.utils.ImageUtils
import com.gh.gamecenter.video.detail.CustomManager
import com.shuyu.gsyvideoplayer.utils.Debuger
import com.shuyu.gsyvideoplayer.utils.GSYVideoType
import com.shuyu.gsyvideoplayer.utils.GSYVideoType.SCREEN_TYPE_FULL
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer
@ -18,18 +17,14 @@ class SplashAdVideoView @JvmOverloads constructor(
) :
StandardGSYVideoPlayer(context, attrs) {
fun startPlay(cover: String, url: String) {
fun startPlay(url: String) {
GSYVideoType.setShowType(SCREEN_TYPE_FULL)
GSYVideoType.setRenderType(GSYVideoType.SUFRACE)
CustomManager.getCustomManager(getKey()).isNeedMute = true
setUp(url, true, "")
val ivCover = findViewById<SimpleDraweeView>(R.id.thumbImage)
ImageUtils.display(ivCover, cover)
setNeedAutoAdaptation(false)
isLooping = true
startPlayLogic()
}
@ -49,6 +44,31 @@ class SplashAdVideoView @JvmOverloads constructor(
return R.layout.layout_splash_ad_video
}
override fun onAutoCompletion() {
setStateAndUi(CURRENT_STATE_AUTO_COMPLETE);
mSaveChangeViewTIme = 0
mCurrentPosition = 0
if (!mIfCurrentIsFullscreen) {
getGSYVideoManager().setLastListener(null)
}
mAudioManager.abandonAudioFocus(onAudioFocusChangeListener);
if (mContext is Activity) {
try {
(mContext as Activity).getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
} catch (e: Exception) {
e.printStackTrace()
}
}
releaseNetWorkState()
if (mVideoAllCallBack != null && isCurrentMediaListener()) {
mVideoAllCallBack.onAutoComplete(mOriginUrl, mTitle, this)
}
mHadPlay = false
}
fun clearAll() {
GSYVideoType.setShowType(GSYVideoType.SCREEN_TYPE_DEFAULT)
GSYVideoType.setRenderType(GSYVideoType.TEXTURE)