調整releaseSurface的呼叫時機

This commit is contained in:
Raymond Yang
2023-03-09 09:06:25 +08:00
parent 2897cdca0d
commit d77fc98280
4 changed files with 17 additions and 11 deletions
@@ -114,6 +114,7 @@ class MainActivity : AppCompatActivity() {
binding.viewPager.setCurrentItem(0, false)
for (i in 0 until splitVideoViewAdapter.itemCount) {
splitVideoViewAdapter.pause(i)
splitVideoViewAdapter.destroy(i)
}
//delay(oldSplitMode * Constants.CONF_DELAY_BASE_MILLIS)
delay((oldSplitMode * 100) + Constants.CONF_DELAY_BASE_MILLIS)
@@ -83,10 +83,10 @@ class SplitViewFragment : Fragment() {
}
override fun onDestroy() {
super.onDestroy()
//destroyAll()
stopAll()
Log.d("${TAG}_$mPageNum", "onDestroy()")
super.onDestroy()
}
private fun initView() {
@@ -214,8 +214,8 @@ class SplitViewFragment : Fragment() {
fun destroyAll() /*= MainScope().launch(Dispatchers.Main)*/ {
if (videoViews.isEmpty()) return
for (index in data.indices) {
videoViews[index].destroy()
//delay(100)
//videoViews[index].destroy()
videoViews[index].destroySurface()
}
}//.start()
@@ -105,8 +105,9 @@ class VideoView : ConstraintLayout, GstCallback {
fun play() {
if (data == null) return
videoView.postInvalidate()
gstLibrary.play()
if (this::gstLibrary.isInitialized) {
gstLibrary.play()
}
}
fun pause() {
@@ -117,6 +118,12 @@ class VideoView : ConstraintLayout, GstCallback {
}
}
fun destroySurface() {
if (this::gstLibrary.isInitialized) {
gstLibrary.releaseSurface()
}
}
fun destroy() {
if (this::gstLibrary.isInitialized) {
gstLibrary.close()