Skip to content

Commit

Permalink
fix: Auto Playing Videos and Discovery's External Browser Pop-Up (#383)
Browse files Browse the repository at this point in the history
* 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 <hamzaisrar12@gmail.com>
  • Loading branch information
dixidroid and HamzaIsrar12 authored Oct 7, 2024
1 parent eddd54b commit 660770c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,6 @@ private fun CourseInfoWebView(
factory = {
webView
},
update = {
webView.loadUrl(contentUrl)
}
)
}

Expand Down

0 comments on commit 660770c

Please sign in to comment.