將停止播放函數改成手動呼叫,測試看看是否還會容易閃退

This commit is contained in:
Raymond Yang 2023-02-02 10:20:00 +08:00
parent de152da749
commit 9fc8673715
2 changed files with 12 additions and 3 deletions

View File

@ -52,7 +52,13 @@ class MainActivity : AppCompatActivity() {
registerOnPageChangeCallback(object: ViewPager2.OnPageChangeCallback() {
override fun onPageSelected(position: Int) {
super.onPageSelected(position)
splitVideoViewAdapter.stop(currentPage)
currentPage = position
Log.d("Split", "currentPage: $currentPage")
/*for (i in 0 until splitVideoViewAdapter.itemCount) {
if (i == currentPage) continue
splitVideoViewAdapter.stop(i)
}*/
}
})
}

View File

@ -55,14 +55,17 @@ class SplitViewFragment : Fragment() {
}
override fun onPause() {
stopAll()
//stopAll()
super.onPause()
Log.d("${TAG}_$mPageNum", "onPause()")
}
override fun onResume() {
super.onResume()
playAll()
MainScope().launch {
delay(1000)
playAll()
}
Log.d("${TAG}_$mPageNum", "onResume()")
}
@ -176,7 +179,7 @@ class SplitViewFragment : Fragment() {
for (index in data.indices) {
videoViews[index].stopRetryCount()
videoViews[index].stop()
delay(300)
delay(500)
}
}