Skip to content

Commit

Permalink
Added PlayerCache clear extension
Browse files Browse the repository at this point in the history
  • Loading branch information
ziad-halabi9 authored and stoyicker committed Sep 19, 2024
1 parent 9bdfe16 commit 4b7dccc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}"
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
}
}
}

0 comments on commit 4b7dccc

Please sign in to comment.