From bbf80f273e275a055dba63890352e09a44ad70cd Mon Sep 17 00:00:00 2001 From: Farhan Arshad <43750646+farhan-arshad-dev@users.noreply.github.com> Date: Mon, 20 Jan 2025 11:36:23 +0500 Subject: [PATCH] fix: issue to load the video through chrome-cast device (#83) fixes: LEARNER-10350 --- .../presentation/unit/video/EncodedVideoUnitViewModel.kt | 1 + .../course/presentation/unit/video/VideoUnitViewModel.kt | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/course/src/main/java/org/openedx/course/presentation/unit/video/EncodedVideoUnitViewModel.kt b/course/src/main/java/org/openedx/course/presentation/unit/video/EncodedVideoUnitViewModel.kt index 17adfcddf..08fde815b 100644 --- a/course/src/main/java/org/openedx/course/presentation/unit/video/EncodedVideoUnitViewModel.kt +++ b/course/src/main/java/org/openedx/course/presentation/unit/video/EncodedVideoUnitViewModel.kt @@ -106,6 +106,7 @@ class EncodedVideoUnitViewModel( CastContext.getSharedInstance(context, executor).addOnCompleteListener { it.result?.let { castContext -> castPlayer = CastPlayer(castContext) + isUpdatedMutable.value = true } } } diff --git a/course/src/main/java/org/openedx/course/presentation/unit/video/VideoUnitViewModel.kt b/course/src/main/java/org/openedx/course/presentation/unit/video/VideoUnitViewModel.kt index 63425ffec..0360d9dc6 100644 --- a/course/src/main/java/org/openedx/course/presentation/unit/video/VideoUnitViewModel.kt +++ b/course/src/main/java/org/openedx/course/presentation/unit/video/VideoUnitViewModel.kt @@ -40,9 +40,9 @@ open class VideoUnitViewModel( val currentVideoTime: LiveData get() = _currentVideoTime - private val _isUpdated = MutableLiveData(true) + protected val isUpdatedMutable = MutableLiveData(true) val isUpdated: LiveData - get() = _isUpdated + get() = isUpdatedMutable private val _currentIndex = MutableStateFlow(0) val currentIndex = _currentIndex.asStateFlow() @@ -63,9 +63,9 @@ open class VideoUnitViewModel( viewModelScope.launch { notifier.notifier.collect { if (it is CourseVideoPositionChanged && videoUrl == it.videoUrl) { - _isUpdated.value = false + isUpdatedMutable.value = false _currentVideoTime.value = it.videoTime - _isUpdated.value = true + isUpdatedMutable.value = true isPlaying = it.isPlaying } else if (it is CourseSubtitleLanguageChanged) { transcriptLanguage = it.value