Skip to content
Snippets Groups Projects
Commit 52add471 authored by Taras's avatar Taras
Browse files

Stop video depend on events

parent 8ea02729
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@ import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import androidx.media3.common.Player
import androidx.media3.exoplayer.ExoPlayer
import androidx.navigation.fragment.findNavController
import androidx.navigation.fragment.navArgs
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.RecyclerView
......@@ -106,6 +107,9 @@ class TimelineDialogFragment : BaseFullscreenDialogFragment(DialogFragmentTimeli
setupViews()
setupObservers()
setupMenu()
findNavController().addOnDestinationChangedListener { _, destination, _ ->
if (destination.id != R.id.timelineFragment) listAdapter.stopVideoPlayback()
}
}
override fun onPause() {
......
......@@ -89,13 +89,14 @@ class TimelineAdapter(
override fun onViewDetachedFromWindow(holder: PostViewHolder) {
super.onViewDetachedFromWindow(holder)
(holder as? MediaViewHolder)?.unTrackMediaLoading()
if (holder == currentPlayingVideoHolder) stopVideoPlayback()
}
override fun onVideoPlaybackStateChanged(holder: VideoPostViewHolder, isPlaying: Boolean) {
currentPlayingVideoHolder = if (isPlaying) holder else null
}
fun stopVideoPlayback(){
fun stopVideoPlayback() {
currentPlayingVideoHolder?.stopVideo()
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment