Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed songUrlCache returning expired urls
Browse files Browse the repository at this point in the history
gechoto authored Jan 11, 2025
1 parent c579fb6 commit 930cc4c
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -63,7 +63,7 @@ class DownloadUtil @Inject constructor(
return@Factory dataSpec
}

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

@@ -98,7 +98,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)
Original file line number Diff line number Diff line change
@@ -631,7 +631,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())
}
@@ -681,7 +681,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)
}
}

0 comments on commit 930cc4c

Please sign in to comment.