Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Auto Playing Videos and Discovery's External Browser Pop-Up #383

Merged
merged 4 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading