Skip to content

Commit 8f4bda2

Browse files
[MBL-19554][Student][Teacher] Video playback conflict: previous MP4 keeps playing when a new one starts
refs: MBL-19554 affects: Student, Teacher release note: Fixed issue where multiple videos would play simultaneously.
1 parent c276d95 commit 8f4bda2

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

libs/pandautils/src/main/java/com/instructure/pandautils/activities/BaseViewMediaActivity.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ abstract class BaseViewMediaActivity : BaseCanvasActivity() {
215215
override fun onResume() {
216216
super.onResume()
217217

218+
// Pause all other playing videos to prevent multiple videos playing simultaneously
219+
ExoAgent.pauseAllOtherAgents(mUri)
220+
218221
val fileFolderDeletedEvent = EventBus.getDefault().getStickyEvent(FileFolderDeletedEvent::class.java)
219222
if (fileFolderDeletedEvent != null)
220223
finish()

libs/pandautils/src/main/java/com/instructure/pandautils/utils/ExoPlayerHelper.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,5 +251,18 @@ class ExoAgent private constructor(val uri: Uri) {
251251
fun releaseAllAgents() {
252252
agentInstances.values.forEach { it.release() }
253253
}
254+
255+
/** Pauses all agents except the one associated with the specified Uri */
256+
fun pauseAllOtherAgents(currentUri: Uri) {
257+
agentInstances.forEach { (uriString, agent) ->
258+
if (uriString != currentUri.toString()) {
259+
agent.mPlayer?.let {
260+
if (it.isPlaying) {
261+
it.playWhenReady = false
262+
}
263+
}
264+
}
265+
}
266+
}
254267
}
255268
}

0 commit comments

Comments
 (0)