mirror of
https://github.com/antebudimir/tempus.git
synced 2026-04-15 16:27:26 +00:00
feat: prefer locally downloaded media vs server stream (#433)
resolves #404 and should address #285
This commit is contained in:
parent
3958cbcc1c
commit
dbd32baa12
5 changed files with 84 additions and 28 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue