fix player session id (#534)

This commit is contained in:
self-similarity 2023-08-02 17:35:41 +00:00 committed by GitHub
parent 2475088f76
commit 3137a68552
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -37,6 +37,7 @@ import com.lagradost.cloudstream3.CommonActivity.showToast
import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.mvvm.logError import com.lagradost.cloudstream3.mvvm.logError
import com.lagradost.cloudstream3.mvvm.normalSafeApiCall import com.lagradost.cloudstream3.mvvm.normalSafeApiCall
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.unixTimeMs
import com.lagradost.cloudstream3.ui.subtitles.SaveCaptionStyle import com.lagradost.cloudstream3.ui.subtitles.SaveCaptionStyle
import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment
import com.lagradost.cloudstream3.utils.AppUtils import com.lagradost.cloudstream3.utils.AppUtils
@ -329,7 +330,10 @@ abstract class AbstractPlayerFragment(
if (player is ExoPlayer) { if (player is ExoPlayer) {
context?.let { ctx -> context?.let { ctx ->
mMediaSession?.release() mMediaSession?.release()
mMediaSession = MediaSession.Builder(ctx, player).build() mMediaSession = MediaSession.Builder(ctx, player)
// Ensure unique ID for concurrent players
.setId(unixTimeMs.toString())
.build()
} }
// Necessary for multiple combined videos // Necessary for multiple combined videos
@ -441,6 +445,7 @@ abstract class AbstractPlayerFragment(
keyEventListener = null keyEventListener = null
canEnterPipMode = false canEnterPipMode = false
mMediaSession?.release() mMediaSession?.release()
mMediaSession = null
SubtitlesFragment.applyStyleEvent -= ::onSubStyleChanged SubtitlesFragment.applyStyleEvent -= ::onSubStyleChanged
keepScreenOn(false) keepScreenOn(false)