Only updates video position when the video is ready to play
This commit is contained in:
+1
-1
@@ -156,7 +156,7 @@ class MultiPlayerPlaybackManager(
|
|||||||
newPosition: PositionInfo,
|
newPosition: PositionInfo,
|
||||||
reason: Int,
|
reason: Int,
|
||||||
) {
|
) {
|
||||||
if (mustCachePositions) {
|
if (mustCachePositions && player.playbackState != STATE_IDLE) {
|
||||||
cachedPositions.add(uri, newPosition.positionMs)
|
cachedPositions.add(uri, newPosition.positionMs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -508,14 +508,20 @@ fun GetVideoController(
|
|||||||
}
|
}
|
||||||
|
|
||||||
onDispose {
|
onDispose {
|
||||||
GlobalScope.launch(Dispatchers.Main) {
|
if (!keepPlaying.value) {
|
||||||
if (!keepPlaying.value) {
|
// Makes sure the variable is cleared before the task is launched
|
||||||
// Stops and releases the media.
|
// to avoid the ON_RELEASE running before ON_PAUSE's coroutine
|
||||||
controller.value?.let {
|
val toRelease = controller.value
|
||||||
|
controller.value = null
|
||||||
|
|
||||||
|
toRelease?.let {
|
||||||
|
it.pause()
|
||||||
|
|
||||||
|
GlobalScope.launch(Dispatchers.Main) {
|
||||||
|
// Stops and releases the media.
|
||||||
it.stop()
|
it.stop()
|
||||||
it.release()
|
it.release()
|
||||||
Log.d("PlaybackService", "Releasing Video $videoUri ")
|
Log.d("PlaybackService", "Releasing Video $videoUri ")
|
||||||
controller.value = null
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user