修复release混淆后,程序运行时序异常导致崩溃的问题
This commit is contained in:
parent
b491186524
commit
b4a2bf3410
|
|
@ -39,7 +39,7 @@ class VersionActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), OnT
|
||||||
|
|
||||||
|
|
||||||
// For Testing
|
// For Testing
|
||||||
val shouldShowDebug = true//BuildConfig.DEBUG
|
val shouldShowDebug = false//BuildConfig.DEBUG
|
||||||
llTesting.isVisible = shouldShowDebug
|
llTesting.isVisible = shouldShowDebug
|
||||||
if (shouldShowDebug) {
|
if (shouldShowDebug) {
|
||||||
butCash.setOnClickListener {
|
butCash.setOnClickListener {
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.YouTubePlayer
|
||||||
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.listeners.AbstractYouTubePlayerListener
|
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.listeners.AbstractYouTubePlayerListener
|
||||||
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.listeners.YouTubePlayerCallback
|
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.listeners.YouTubePlayerCallback
|
||||||
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.utils.loadOrCueVideo
|
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.utils.loadOrCueVideo
|
||||||
|
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.options.IFramePlayerOptions
|
||||||
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView
|
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView
|
||||||
import com.viddin.videos.free.databinding.VididinappFeatureHomeItemLayoutBinding as ViewBinding
|
import com.viddin.videos.free.databinding.VididinappFeatureHomeItemLayoutBinding as ViewBinding
|
||||||
|
|
||||||
|
|
@ -177,83 +178,88 @@ class HomeItemFragment : AppViewsEmptyViewModelFragment<ViewBinding>() {
|
||||||
layoutParam.gravity = Gravity.BOTTOM
|
layoutParam.gravity = Gravity.BOTTOM
|
||||||
binding!!.playerContainer.addView(mPlayerView, layoutParam)
|
binding!!.playerContainer.addView(mPlayerView, layoutParam)
|
||||||
lifecycle.addObserver(mPlayerView!!)
|
lifecycle.addObserver(mPlayerView!!)
|
||||||
mPlayerView?.enableAutomaticInitialization = true
|
mPlayerView?.enableAutomaticInitialization = false
|
||||||
|
|
||||||
|
val iFramePlayerOptions = IFramePlayerOptions.Builder(requireActivity())
|
||||||
|
.controls(0)
|
||||||
|
.rel(0)
|
||||||
|
.ivLoadPolicy(3)
|
||||||
|
.ccLoadPolicy(1)
|
||||||
|
.build()
|
||||||
|
|
||||||
|
mPlayerView!!.initialize(object : AbstractYouTubePlayerListener() {
|
||||||
|
override fun onReady(youTubePlayer: YouTubePlayer) {
|
||||||
|
mPlayer = youTubePlayer
|
||||||
|
val playerUiController = MyPlayerControlView(mPlayerView!!)
|
||||||
|
mPlayerView!!.setCustomPlayerUi(playerUiController.rootView)
|
||||||
|
|
||||||
|
if (mPendingPlay) {
|
||||||
|
mPlayer?.loadVideo(mVideoData!!.id, mCurPlayedSecond)
|
||||||
|
} else if (mIsPreloading) {
|
||||||
|
mPlayer?.mute()
|
||||||
|
mPlayer?.loadVideo(mVideoData!!.id, mCurPlayedSecond)
|
||||||
|
} else {
|
||||||
|
mPlayer?.cueVideo(mVideoData!!.id, mCurPlayedSecond)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCurrentSecond(youTubePlayer: YouTubePlayer, second: Float) {
|
||||||
|
super.onCurrentSecond(youTubePlayer, second)
|
||||||
|
mCurPlayedSecond = second
|
||||||
|
updateProgressbar()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onVideoDuration(youTubePlayer: YouTubePlayer, duration: Float) {
|
||||||
|
super.onVideoDuration(youTubePlayer, duration)
|
||||||
|
mTotalDuration = duration
|
||||||
|
mTickerTimer.setVideoInfo(mVideoData!!.id, (1000L * mTotalDuration).toLong())
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onStateChange(
|
||||||
|
youTubePlayer: YouTubePlayer,
|
||||||
|
state: PlayerConstants.PlayerState
|
||||||
|
) {
|
||||||
|
when (state) {
|
||||||
|
PlayerConstants.PlayerState.PLAYING -> {
|
||||||
|
if (mIsPreloading) {
|
||||||
|
mPlayer?.pause()
|
||||||
|
} else {
|
||||||
|
togglePlayingState(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PlayerConstants.PlayerState.PAUSED -> {
|
||||||
|
if (mIsPreloading) {
|
||||||
|
// Do nothing or ensure mask is visible?
|
||||||
|
// togglePlayingState(false) sets mask visible.
|
||||||
|
togglePlayingState(false)
|
||||||
|
} else {
|
||||||
|
togglePlayingState(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PlayerConstants.PlayerState.UNKNOWN -> {
|
||||||
|
togglePlayingState(false)
|
||||||
|
}
|
||||||
|
PlayerConstants.PlayerState.UNSTARTED -> {
|
||||||
|
togglePlayingState(false)
|
||||||
|
}
|
||||||
|
PlayerConstants.PlayerState.ENDED -> {
|
||||||
|
togglePlayingState(false)
|
||||||
|
if (!mIsPreloading) {
|
||||||
|
mCurPlayedSecond = 0f
|
||||||
|
mPlayer?.loadVideo(mVideoData!!.id, 0f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PlayerConstants.PlayerState.BUFFERING -> {
|
||||||
|
//binding?.circlePb?.isVisible = true
|
||||||
|
//showLoading(true)
|
||||||
|
}
|
||||||
|
PlayerConstants.PlayerState.VIDEO_CUED -> {
|
||||||
|
togglePlayingState(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, true, iFramePlayerOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
// val playerUiController = MyPlayerControlView(mPlayerView!!)
|
|
||||||
// mPlayerView!!.setCustomPlayerUi(playerUiController.rootView)
|
|
||||||
mPlayerView!!.removeViews(1, mPlayerView!!.childCount - 1)
|
|
||||||
|
|
||||||
mPlayerView!!.addYouTubePlayerListener(object : AbstractYouTubePlayerListener() {
|
|
||||||
override fun onReady(youTubePlayer: YouTubePlayer) {
|
|
||||||
mPlayer = youTubePlayer
|
|
||||||
|
|
||||||
if (mPendingPlay) {
|
|
||||||
mPlayer?.loadVideo(mVideoData!!.id, mCurPlayedSecond)
|
|
||||||
} else if (mIsPreloading) {
|
|
||||||
mPlayer?.mute()
|
|
||||||
mPlayer?.loadVideo(mVideoData!!.id, mCurPlayedSecond)
|
|
||||||
} else {
|
|
||||||
mPlayer?.cueVideo(mVideoData!!.id, mCurPlayedSecond)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCurrentSecond(youTubePlayer: YouTubePlayer, second: Float) {
|
|
||||||
super.onCurrentSecond(youTubePlayer, second)
|
|
||||||
mCurPlayedSecond = second
|
|
||||||
updateProgressbar()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onVideoDuration(youTubePlayer: YouTubePlayer, duration: Float) {
|
|
||||||
super.onVideoDuration(youTubePlayer, duration)
|
|
||||||
mTotalDuration = duration
|
|
||||||
mTickerTimer.setVideoInfo(mVideoData!!.id, (1000L * mTotalDuration).toLong())
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onStateChange(
|
|
||||||
youTubePlayer: YouTubePlayer,
|
|
||||||
state: PlayerConstants.PlayerState
|
|
||||||
) {
|
|
||||||
when (state) {
|
|
||||||
PlayerConstants.PlayerState.PLAYING -> {
|
|
||||||
if (mIsPreloading) {
|
|
||||||
mPlayer?.pause()
|
|
||||||
} else {
|
|
||||||
togglePlayingState(true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PlayerConstants.PlayerState.PAUSED -> {
|
|
||||||
if (mIsPreloading) {
|
|
||||||
// Do nothing or ensure mask is visible?
|
|
||||||
// togglePlayingState(false) sets mask visible.
|
|
||||||
togglePlayingState(false)
|
|
||||||
} else {
|
|
||||||
togglePlayingState(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PlayerConstants.PlayerState.UNKNOWN -> {
|
|
||||||
togglePlayingState(false)
|
|
||||||
}
|
|
||||||
PlayerConstants.PlayerState.UNSTARTED -> {
|
|
||||||
togglePlayingState(false)
|
|
||||||
}
|
|
||||||
PlayerConstants.PlayerState.ENDED -> {
|
|
||||||
togglePlayingState(false)
|
|
||||||
if (!mIsPreloading) {
|
|
||||||
mCurPlayedSecond = 0f
|
|
||||||
mPlayer?.loadVideo(mVideoData!!.id, 0f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PlayerConstants.PlayerState.BUFFERING -> {
|
|
||||||
//binding?.circlePb?.isVisible = true
|
|
||||||
//showLoading(true)
|
|
||||||
}
|
|
||||||
PlayerConstants.PlayerState.VIDEO_CUED -> {
|
|
||||||
togglePlayingState(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun sendPlayStopStatistic(isPlayStart: Boolean) {
|
private fun sendPlayStopStatistic(isPlayStart: Boolean) {
|
||||||
|
|
@ -285,7 +291,15 @@ class HomeItemFragment : AppViewsEmptyViewModelFragment<ViewBinding>() {
|
||||||
// binding?.circlePb?.isVisible = false
|
// binding?.circlePb?.isVisible = false
|
||||||
// }
|
// }
|
||||||
|
|
||||||
binding?.ivMask?.isVisible = !mIsPlaying
|
if (mIsPlaying) {
|
||||||
|
// Delay hiding mask to prevent seeing loading controls
|
||||||
|
binding?.ivMask?.postDelayed({
|
||||||
|
if (mIsPlaying) binding?.ivMask?.isVisible = false
|
||||||
|
}, 500)
|
||||||
|
} else {
|
||||||
|
binding?.ivMask?.isVisible = true
|
||||||
|
}
|
||||||
|
|
||||||
// Ensure playerContainer is visible when playing OR preloading (masked)
|
// Ensure playerContainer is visible when playing OR preloading (masked)
|
||||||
binding?.playerContainer?.isVisible = mIsPlaying || mIsPreloading
|
binding?.playerContainer?.isVisible = mIsPlaying || mIsPreloading
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,10 @@ abstract class BaseTaskHelper<T: Any, C: Any> {
|
||||||
return mStateBean
|
return mStateBean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isReady(): Boolean {
|
||||||
|
return this::mStateBean.isInitialized
|
||||||
|
}
|
||||||
|
|
||||||
fun release() {
|
fun release() {
|
||||||
NotifyMan.instance().unregister(mEventCallback)
|
NotifyMan.instance().unregister(mEventCallback)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -209,6 +209,7 @@ class BoxTaskHelper: BaseTaskHelper<TaskStateBoxRoot, BoxTaskRoot>() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getCurrentBoxStartTimeMs(): Long {
|
fun getCurrentBoxStartTimeMs(): Long {
|
||||||
|
if (!isReady()) return 0L
|
||||||
return mStateBean.boxList[mStateBean.currentBoxIndex].boxStartMs
|
return mStateBean.boxList[mStateBean.currentBoxIndex].boxStartMs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
BIN
vidiDinKey
BIN
vidiDinKey
Binary file not shown.
Loading…
Reference in New Issue