Skip to content

Commit

Permalink
app: fixed songUrlCache returning expired urls
Browse files Browse the repository at this point in the history
  • Loading branch information
gechoto authored Jan 11, 2025
1 parent 64344d3 commit 5805f96
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class DownloadUtil @Inject constructor(
throw PlaybackException("Local song are non-downloadable", null, PlaybackException.ERROR_CODE_UNSPECIFIED)
}

songUrlCache[mediaId]?.takeIf { it.second < System.currentTimeMillis() }?.let {
songUrlCache[mediaId]?.takeIf { it.second > System.currentTimeMillis() }?.let {
return@Factory dataSpec.withUri(it.first.toUri())
}

Expand Down Expand Up @@ -102,7 +102,7 @@ class DownloadUtil @Inject constructor(
"${it}&range=0-${format.contentLength ?: 10000000}"
}

songUrlCache[mediaId] = streamUrl to playbackData.streamExpiresInSeconds * 1000L
songUrlCache[mediaId] = streamUrl to System.currentTimeMillis() + (playbackData.streamExpiresInSeconds * 1000L)
dataSpec.withUri(streamUrl.toUri())
}
val downloadNotificationHelper = DownloadNotificationHelper(context, ExoDownloadService.CHANNEL_ID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ class MusicService : MediaLibraryService(),
return@Factory dataSpec
}

songUrlCache[mediaId]?.takeIf { it.second < System.currentTimeMillis() }?.let {
songUrlCache[mediaId]?.takeIf { it.second > System.currentTimeMillis() }?.let {
scope.launch(Dispatchers.IO) { recoverSong(mediaId) }
return@Factory dataSpec.withUri(it.first.toUri())
}
Expand Down Expand Up @@ -727,7 +727,7 @@ class MusicService : MediaLibraryService(),

val streamUrl = playbackData.streamUrl

songUrlCache[mediaId] = streamUrl to playbackData.streamExpiresInSeconds * 1000L
songUrlCache[mediaId] = streamUrl to System.currentTimeMillis() + (playbackData.streamExpiresInSeconds * 1000L)
dataSpec.withUri(streamUrl.toUri()).subrange(dataSpec.uriPositionOffset, CHUNK_LENGTH)
}
}
Expand Down

0 comments on commit 5805f96

Please sign in to comment.