Skip to content

Commit

Permalink
Temporarily use ConcatenatingMediaSource as fallback (#1511)
Browse files Browse the repository at this point in the history
Torrents seem to fail otherwise with "Must add at least one source to the concatenation", as mediaItemSlices.size is 0. I suspect the cause may be due to `loadExo(context, listOf(), listOf(), null)`
  • Loading branch information
Luna712 authored Jan 26, 2025
1 parent 7d2f898 commit bc7617f
Showing 1 changed file with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import androidx.media3.exoplayer.drm.DefaultDrmSessionManager
import androidx.media3.exoplayer.drm.FrameworkMediaDrm
import androidx.media3.exoplayer.drm.LocalMediaDrmCallback
import androidx.media3.exoplayer.source.ClippingMediaSource
import androidx.media3.exoplayer.source.ConcatenatingMediaSource
import androidx.media3.exoplayer.source.ConcatenatingMediaSource2
import androidx.media3.exoplayer.source.DefaultMediaSourceFactory
import androidx.media3.exoplayer.source.MergingMediaSource
Expand Down Expand Up @@ -838,17 +839,32 @@ class CS3IPlayer : IPlayer {
factory.createMediaSource(item.mediaItem)
}
} else {
val source = ConcatenatingMediaSource2.Builder()
mediaItemSlices.map { item ->
source.add(
// The duration MUST be known for it to work properly, see https://github.com/google/ExoPlayer/issues/4727
ClippingMediaSource(
factory.createMediaSource(item.mediaItem),
item.durationUs
try {
val source = ConcatenatingMediaSource2.Builder()
mediaItemSlices.map { item ->
source.add(
// The duration MUST be known for it to work properly, see https://github.com/google/ExoPlayer/issues/4727
ClippingMediaSource(
factory.createMediaSource(item.mediaItem),
item.durationUs
)
)
)
}
source.build()
} catch(_: IllegalArgumentException) {
@Suppress("DEPRECATION")
val source = ConcatenatingMediaSource() // FIXME figure out why ConcatenatingMediaSource2 seems to fail with Torrents only
mediaItemSlices.map { item ->
source.addMediaSource(
// The duration MUST be known for it to work properly, see https://github.com/google/ExoPlayer/issues/4727
ClippingMediaSource(
factory.createMediaSource(item.mediaItem),
item.durationUs
)
)
}
source
}
source.build()
}

//println("PLAYBACK POS $playbackPosition")
Expand Down

0 comments on commit bc7617f

Please sign in to comment.