mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Small player release fix
This commit is contained in:
parent
09e04033e7
commit
30511906a8
1 changed files with 12 additions and 5 deletions
|
@ -46,6 +46,7 @@ import com.lagradost.cloudstream3.AcraApplication.Companion.getKey
|
||||||
import com.lagradost.cloudstream3.AcraApplication.Companion.setKey
|
import com.lagradost.cloudstream3.AcraApplication.Companion.setKey
|
||||||
import com.lagradost.cloudstream3.USER_AGENT
|
import com.lagradost.cloudstream3.USER_AGENT
|
||||||
import com.lagradost.cloudstream3.app
|
import com.lagradost.cloudstream3.app
|
||||||
|
import com.lagradost.cloudstream3.mvvm.debugAssert
|
||||||
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.ui.subtitles.SaveCaptionStyle
|
import com.lagradost.cloudstream3.ui.subtitles.SaveCaptionStyle
|
||||||
|
@ -78,6 +79,12 @@ const val toleranceAfterUs = 300_000L
|
||||||
class CS3IPlayer : IPlayer {
|
class CS3IPlayer : IPlayer {
|
||||||
private var isPlaying = false
|
private var isPlaying = false
|
||||||
private var exoPlayer: ExoPlayer? = null
|
private var exoPlayer: ExoPlayer? = null
|
||||||
|
set(value) {
|
||||||
|
// If the old value is not null then the player has not been properly released.
|
||||||
|
debugAssert({ field != null && value != null }, { "Previous player instance should be released!" })
|
||||||
|
field = value
|
||||||
|
}
|
||||||
|
|
||||||
var cacheSize = 0L
|
var cacheSize = 0L
|
||||||
var simpleCacheSize = 0L
|
var simpleCacheSize = 0L
|
||||||
var videoBufferMs = 0L
|
var videoBufferMs = 0L
|
||||||
|
@ -710,13 +717,13 @@ class CS3IPlayer : IPlayer {
|
||||||
metadataRendererOutput
|
metadataRendererOutput
|
||||||
).map {
|
).map {
|
||||||
if (it is TextRenderer) {
|
if (it is TextRenderer) {
|
||||||
currentTextRenderer = CustomTextRenderer(
|
val currentTextRenderer = CustomTextRenderer(
|
||||||
subtitleOffset,
|
subtitleOffset,
|
||||||
textRendererOutput,
|
textRendererOutput,
|
||||||
eventHandler.looper,
|
eventHandler.looper,
|
||||||
CustomSubtitleDecoderFactory()
|
CustomSubtitleDecoderFactory()
|
||||||
)
|
).also { this.currentTextRenderer = it }
|
||||||
currentTextRenderer!!
|
currentTextRenderer
|
||||||
} else it
|
} else it
|
||||||
}.toTypedArray()
|
}.toTypedArray()
|
||||||
}
|
}
|
||||||
|
@ -1307,7 +1314,7 @@ class CS3IPlayer : IPlayer {
|
||||||
override fun reloadPlayer(context: Context) {
|
override fun reloadPlayer(context: Context) {
|
||||||
Log.i(TAG, "reloadPlayer")
|
Log.i(TAG, "reloadPlayer")
|
||||||
|
|
||||||
exoPlayer?.release()
|
releasePlayer(false)
|
||||||
currentLink?.let {
|
currentLink?.let {
|
||||||
loadOnlinePlayer(context, it)
|
loadOnlinePlayer(context, it)
|
||||||
} ?: currentDownloadedFile?.let {
|
} ?: currentDownloadedFile?.let {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue