Skip to content

Commit

Permalink
Merge pull request #43 from edx/2U/omer/LEARNER-10178
Browse files Browse the repository at this point in the history
fix: Casting method update + crash fix
  • Loading branch information
farhan-arshad-dev authored Sep 4, 2024
2 parents 0dc3065 + 4f18de1 commit b28b6e2
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,8 @@ class EncodedVideoUnitViewModel(
initPlayer()

val executor = Executors.newSingleThreadExecutor()
CastContext.getSharedInstance(context, executor).addOnCompleteListener {
it.result?.let { castContext ->
castPlayer = CastPlayer(castContext)
}
CastContext.getSharedInstance(context, executor).result?.let { castContext ->
castPlayer = CastPlayer(castContext)
}
}

Expand All @@ -119,8 +117,12 @@ class EncodedVideoUnitViewModel(

override fun onPause(owner: LifecycleOwner) {
super.onPause(owner)
exoPlayer?.removeListener(exoPlayerListener)
exoPlayer?.pause()
if (isCastActive) {
getActivePlayer()?.release()
} else {
exoPlayer?.removeListener(exoPlayerListener)
exoPlayer?.pause()
}
}

fun getActivePlayer(): Player? {
Expand Down

0 comments on commit b28b6e2

Please sign in to comment.