diff --git a/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/ExoPlayerPlaybackEngine.kt b/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/ExoPlayerPlaybackEngine.kt index e89b371b..3267fe6a 100644 --- a/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/ExoPlayerPlaybackEngine.kt +++ b/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/ExoPlayerPlaybackEngine.kt @@ -57,6 +57,7 @@ import com.tidal.sdk.player.playbackengine.player.ExtendedExoPlayerFactory import com.tidal.sdk.player.playbackengine.player.PlayerCache import com.tidal.sdk.player.playbackengine.quality.AudioQualityRepository import com.tidal.sdk.player.playbackengine.util.SynchronousSurfaceHolder +import com.tidal.sdk.player.playbackengine.util.clear import com.tidal.sdk.player.playbackengine.view.AspectRatioAdjustingSurfaceView import com.tidal.sdk.player.playbackengine.volume.VolumeHelper import com.tidal.sdk.player.streamingapi.playbackinfo.model.PlaybackInfo @@ -810,11 +811,7 @@ internal class ExoPlayerPlaybackEngine( while (crawler?.cause != null) { @Suppress("MagicNumber") if ((crawler as? InvalidResponseCodeException)?.responseCode == 416) { - with(playerCache.cache) { - keys.forEach { - removeResource(it) - } - } + playerCache.clear() } crawler = crawler.cause errorMessage += " -> ${crawler?.message}" diff --git a/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/util/PlayerCacheExtensions.kt b/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/util/PlayerCacheExtensions.kt new file mode 100644 index 00000000..b652bff1 --- /dev/null +++ b/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/util/PlayerCacheExtensions.kt @@ -0,0 +1,11 @@ +package com.tidal.sdk.player.playbackengine.util + +import com.tidal.sdk.player.playbackengine.player.PlayerCache + +internal fun PlayerCache.clear() { + with(cache) { + keys.forEach { + removeResource(it) + } + } +}