androidx / androidx/media

Is it possible to enable the videotrack without a pause in the playback?

Open
#2,316 11 comments 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

question
Dominant language
Java
Stars
3k
Forks
955
Avg merge
12d 14h
Merged PRs (30d)
2

Description

I'm working on an audio streaming app that uses ExoPlayer and Media3, with all content delivered via HLS streams.

We're now adding video podcasts to the app. I’ve implemented dynamic video track selection so users can enable or disable video based on preference or device state (e.g., screen off), minimizing bandwidth usage when video isn't needed.

I have done it like this:

val builder = exoPlayer.trackSelectionParameters.buildUpon()
if (isAppInForeground && isVideoWantedByUser) {
            builder.clearOverridesOfType(TRACK_TYPE_VIDEO)
        } else {
            builder
                .addOverride(
                    TrackSelectionOverride(
                        videoGroup.mediaTrackGroup, listOf()
                    )
                )
        }

The issue I'm facing is that enabling the video track causes a brief pause in playback—likely due to the video buffering. I'm wondering if there's a way to prioritize audio playback over video, so that enabling video doesn't interrupt the ongoing audio stream. Ideally, video would load in the background and start displaying once buffered, without causing any playback disruption.

Note that my iOS counterpart did a similar implementation and has this working without the disruption.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.