將延遲參數常數化

This commit is contained in:
Raymond Yang 2023-02-08 10:28:40 +08:00
parent 4cf5ae5094
commit 53763bfa34
2 changed files with 7 additions and 5 deletions

View File

@ -1,5 +1,5 @@
package com.ray650128.gstreamer_demo_app
object Constants {
const val CONF_DELAY_BASE_MILLIS = 300L
const val CONF_DELAY_BASE_MILLIS = 500L
}

View File

@ -9,6 +9,7 @@ import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.gridlayout.widget.GridLayout
import com.ray650128.gstreamer_demo_app.Constants
import com.ray650128.gstreamer_demo_app.databinding.FragmentSplitViewBinding
import com.ray650128.gstreamer_demo_app.dp
import com.ray650128.gstreamer_demo_app.model.Device
@ -67,7 +68,7 @@ class SplitViewFragment : Fragment() {
}
override fun onPause() {
//stopAll()
stopAll()
super.onPause()
Log.d("${TAG}_$mPageNum", "onPause()")
}
@ -76,7 +77,7 @@ class SplitViewFragment : Fragment() {
super.onResume()
if (viewModel.activePage.value == mPageNum) {
MainScope().launch {
delay(splitMode * 500L)
delay(splitMode * Constants.CONF_DELAY_BASE_MILLIS)
playAll()
}
}
@ -156,7 +157,7 @@ class SplitViewFragment : Fragment() {
}
MainScope().launch {
stopAll()
delay(splitMode * 300L)
delay(splitMode * Constants.CONF_DELAY_BASE_MILLIS)
val item = data[position]
val bundle = Bundle().apply {
//putInt(MonitoringActivity.BUNDLE_DEVICE_ID, item.id)
@ -196,8 +197,9 @@ class SplitViewFragment : Fragment() {
if (videoViews.isEmpty()) return@launch
for (index in data.indices) {
videoViews[index].stopRetryCount()
if (!videoViews[index].isPlaying || videoViews[index].isLoading) continue
videoViews[index].stop()
delay(300)
delay(100)
}
}.start()