I have a viewPager where i display both images and Video. However, when a user plays a video and immediately swipes to the next fragment, the previous Video continues to PLAY!
Here's how i played the video
videoView!!.setVideoURI(uri)
videoView!!.setMediaController(MediaController(context))
videoView!!.requestFocus()
play.setOnClickListener(View.OnClickListener {
if (!videoView!!.isPlaying()) {
videoView!!.start()
videoView!!.setVisibility(View.VISIBLE)
}
I have tried inserting
if (videoView!!.isPlaying()) {
videoView!!.setMediaController(null)
videoView?.stopPlayback()
}
in onStop, onPause and onDetach of the viewPager's fragment but it is not working.
Your help would be invaluable!