feat: prefer locally downloaded media vs server stream (#433)

resolves #404 and should address #285
This commit is contained in:
eddyizm 2026-02-11 21:31:46 -08:00 committed by GitHub
parent 3958cbcc1c
commit dbd32baa12
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 84 additions and 28 deletions

View file

@ -33,12 +33,18 @@ class TranscodingMediaSource(
init {
val extras = mediaItem.mediaMetadata.extras
if (extras != null && extras.containsKey("duration")) {
val uri = mediaItem.localConfiguration?.uri
val isLocal = uri?.scheme == "content" || uri?.scheme == "file"
// Only apply the override if it's NOT a local file
if (!isLocal && extras != null && extras.containsKey("duration")) {
val seconds = extras.getInt("duration")
if (seconds > 0) {
durationUs = Util.msToUs(seconds * 1000L)
}
}
currentSource = progressiveMediaSourceFactory.createMediaSource(mediaItem)
}
override fun getMediaItem() = mediaItem