From 660770ce01f87509567324d0d8979912834cf653 Mon Sep 17 00:00:00 2001 From: Igor Date: Mon, 7 Oct 2024 11:15:35 +0200 Subject: [PATCH] fix: Auto Playing Videos and Discovery's External Browser Pop-Up (#383) * fix: Open in External Browser Pop-Up for Bachelor's Degrees * fix: Multiple videos playing simultaneously * fix: Retain Video Seek Time when Exiting Fullscreen in Native Videos --------- Co-authored-by: Hamza Israr --- .../course/presentation/unit/video/VideoUnitFragment.kt | 3 ++- .../presentation/unit/video/YoutubeVideoUnitFragment.kt | 9 ++++++++- .../discovery/presentation/info/CourseInfoFragment.kt | 3 --- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/course/src/main/java/org/openedx/course/presentation/unit/video/VideoUnitFragment.kt b/course/src/main/java/org/openedx/course/presentation/unit/video/VideoUnitFragment.kt index d92b3b067..276f48574 100644 --- a/course/src/main/java/org/openedx/course/presentation/unit/video/VideoUnitFragment.kt +++ b/course/src/main/java/org/openedx/course/presentation/unit/video/VideoUnitFragment.kt @@ -201,9 +201,10 @@ class VideoUnitFragment : Fragment(R.layout.fragment_video_unit) { if (!viewModel.isPlayerSetUp) { setPlayerMedia(mediaItem) viewModel.getActivePlayer()?.prepare() - viewModel.getActivePlayer()?.playWhenReady = viewModel.isPlaying + viewModel.getActivePlayer()?.playWhenReady = viewModel.isPlaying && isResumed viewModel.isPlayerSetUp = true } + viewModel.getActivePlayer()?.seekTo(viewModel.getCurrentVideoTime()) viewModel.castPlayer?.setSessionAvailabilityListener( object : SessionAvailabilityListener { diff --git a/course/src/main/java/org/openedx/course/presentation/unit/video/YoutubeVideoUnitFragment.kt b/course/src/main/java/org/openedx/course/presentation/unit/video/YoutubeVideoUnitFragment.kt index 8ee99b970..e6b04687d 100644 --- a/course/src/main/java/org/openedx/course/presentation/unit/video/YoutubeVideoUnitFragment.kt +++ b/course/src/main/java/org/openedx/course/presentation/unit/video/YoutubeVideoUnitFragment.kt @@ -84,6 +84,13 @@ class YoutubeVideoUnitFragment : Fragment(R.layout.fragment_youtube_video_unit) return binding.root } + override fun onResume() { + super.onResume() + if (viewModel.isPlaying) { + _youTubePlayer?.play() + } + } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) @@ -202,7 +209,7 @@ class YoutubeVideoUnitFragment : Fragment(R.layout.fragment_youtube_video_unit) } viewModel.videoUrl.split("watch?v=").getOrNull(1)?.let { videoId -> - if (viewModel.isPlaying) { + if (viewModel.isPlaying && isResumed) { youTubePlayer.loadVideo( videoId, viewModel.getCurrentVideoTime().toFloat() / 1000 ) diff --git a/discovery/src/main/java/org/openedx/discovery/presentation/info/CourseInfoFragment.kt b/discovery/src/main/java/org/openedx/discovery/presentation/info/CourseInfoFragment.kt index b3b3275eb..d34233f1b 100644 --- a/discovery/src/main/java/org/openedx/discovery/presentation/info/CourseInfoFragment.kt +++ b/discovery/src/main/java/org/openedx/discovery/presentation/info/CourseInfoFragment.kt @@ -347,9 +347,6 @@ private fun CourseInfoWebView( factory = { webView }, - update = { - webView.loadUrl(contentUrl) - } ) }