CompositionPlayer fails to play overlapped EditedMediaItemSequence items
Open
@droid-girl is already working on this.
Since Nov 3, 2025.
bug
editing
- Dominant language
- Java
- Stars
- 3k
- Forks
- 955
- Avg merge
- 12d 14h
- Merged PRs (30d)
- 2
Description
Version
Media3 pre-release (alpha, beta or RC not in this list)
More version details
Version 1.9.0-alpha01
Devices that reproduce the issue
- Pixel 7 Pro running Android 16
- Samsung S10 running Android 12
Devices that do not reproduce the issue
None found
Reproducible in the demo app?
Not tested
Reproduction steps
Attempt to create a cross over video fade effect...
- Create a list of EditedMediaItemSequence which have one media item each. Have each EditedMediaItemSequence cross over by adding gaps at the start and end to pad out the spacing.
const val CROSS_OVER_MS = 1000L
const val US_PER_MS = 1000L
fun buildComposition(context: Context, uris: List<Uri>): Composition {
val durationsMs = uris.map {
getVideoDurationMs(context, it)
}
val startTimesMs = durationsMs.mapIndexed { index, duration ->
durationsMs.take(index).sum() - (index * CROSS_OVER_MS)
}
val totalMs = startTimesMs.last() + durationsMs.last()
val sequences = uris.mapIndexed { index, uri ->
val durationMs = durationsMs[index]
val startGapMs = startTimesMs[index]
val endGapMs = totalMs - startGapMs - durationMs
val mediaItem = MediaItem.fromUri(uri)
val editedMediaItem = EditedMediaItem.Builder(mediaItem)
.setDurationUs(durationMs * US_PER_MS)
.setFrameRate(30)
.build()
EditedMediaItemSequence
.Builder(setOf(C.TRACK_TYPE_VIDEO, C.TRACK_TYPE_AUDIO))
.also {
if (startGapMs > 0L) it.addGap(startGapMs * US_PER_MS)
}
.addItem(editedMediaItem)
.also {
if (endGapMs > 0) it.addGap(endGapMs * US_PER_MS)
}
.build()
}
... rest of function in step 3
- Create a custom VideoCompositionSettings which fades the video in/out as needed
class MyVideoCompositionSettings(private val changeTimesMs: List<Long>) : VideoCompositorSettings {
override fun getOutputSize(inputSizes: List<Size>): Size {
return inputSizes.maxBy { it.width }
}
override fun getOverlaySettings(inputId: Int, presentationTimeUs: Long): OverlaySettings {
val startUs = if (inputId > 0) changeTimesMs[inputId - 1] * US_PER_MS else 0L
val endUs = changeTimesMs[inputId] * US_PER_MS
val isVisible = presentationTimeUs in startUs..endUs
// Calculate alpha based on cross over time (omitted for simplicity)
return StaticOverlaySettings.Builder()
.setAlphaScale(if(isVisible) 1F else 0F)
.build()
}
}
- Create the composition
// Follow on from code in step 1
val changeOverTimes = startTimesMs.mapIndexed { index, start -> start + durationsMs[index] }
val videoCompositionSettings = MyVideoCompositionSettings(changeOverTimes)
return Composition.Builder(sequences)
.setVideoCompositorSettings(videoCompositionSettings)
.build()
}
- Play the composition in a CompositionPlayer
Expected result
The videos play in sequence with some cross over and fade effect (once alpha calculation added to VideoCompositionSettings)
Actual result
- The player plays the first video then stops at the last frame of the first video. The seek bar and time keep going. The playback time does not stop at the end of the video either (e.g. 10 second total video will keep counting up and not stop at 10 seconds)
- If audio is enabled then audio for second item can still be heard
- Note that exporting the video using a Transformer works without fault.
- Also removing the cross over (setting CROSS_OVER_MS to 0) works without fault.
https://github.com/user-attachments/assets/96998000-559f-434a-a775-0790bc691b0d
Media
https://github.com/user-attachments/assets/84de1b71-38d9-4167-af9b-9601c13909c4
https://github.com/user-attachments/assets/a3d369ce-138a-4035-98d2-0374e03affaf
Bug Report
- You will email the zip file produced by
adb bugreportto android-media-github@google.com after filing this issue.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.