androidx / androidx/media

Impossible to have correct first frame video playback?

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

@tianyif is already working on this.

Since May 22, 2025.

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

Description

Is there a way to wait tell Exoplayer to load the video just enough to get its dimensions before attaching a Surface/Texture View to display it?

We have a case where we want to do some scaling & alignment but do not know the video dimensions before hand. Its a HLS adaptive stream so most likely no way to determine the video dimensions without being on device and loading and selecting track.

So far, I have to

  • attach a surface first
  • then the video gets loaded (which reports its size to my listener)
  • only then can I do my scaling

Problem is when i attach the surface it will load & display a frame at the unwanted size, before relayout happens at the next frame, and my video size based logic then kicks in. Very jarring.

My current workaround is to measure with a size of 1 x 1 initially, this will allow the player to start loading the video and report the correct video size maybe a frame or two later and then do the scaling when I have the proper dimensions.


I would like to be able to load a HLS video (ie do the bandwidth calculations, select the correct variant, etc) before a surface is even attached.

I would also like to be able to tell from this "preloaded video" its size at the point we are configuring the player, that way I can also have my layout logic ready to be based on the video size from frame 1.

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.