-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom MediaSources, resolving MediaItems from remote API, and metadata updates #11031
Comments
Regarding the topic of metadata during playback. The docs mention a mechanism for receiving this metadata by "adding a |
Since you're using media3 can you please re-post this on the media3 issue tracker (this tracker should only be used for apps using the |
Apologies, I was under the impression that since this was more specifically about the ExoPlayer parts of media3 that it should be posted here (doesn't help that the media3 repo has a note in their question issue template about coming here for exoplayer related questions). |
You're right, that wording isn't super clear. sorry about that - it's meant to be saying 'search for existing issues on the exoplayer tracker'. I've sent a change to clarify that, and also more clearly call out in the templates of this tracker that it should only be used by apps using the (generally it doesn't really matter which tracker we use for exoplayer-only issues, but because you're also discussing media3-only bits like |
Issue: google/ExoPlayer#11031 #minor-release PiperOrigin-RevId: 514366016
Issue: #11031 #minor-release PiperOrigin-RevId: 514366016
Issue: google/ExoPlayer#11031 #minor-release PiperOrigin-RevId: 514366016 (cherry picked from commit 9c82923)
I've searched around extensively on this repository, on the
androidx/media
repository, on stack overflow, and I've been browsing through the source to determine the best course of action for my use case but I haven't really found much, and I've run into issues or gaps in the explanation on the information I have found.The use case I have seems like it calls for custom media sources, for the most part it isn't complex, it's a case of loading the media based upon an internal URI system. But there are some additional complexities when it comes to the type of media to load.
Key details:
mydatastorescheme://podcast/{id}
) and the rest is handled opaquely inside the Media code.In Media3 there is the
MediaSession
callback with the requiredonAddMediaItems
function. This function works fine for loading the correct audio URLs and metadata for a particular bit of content referenced by one of my internal URIs. e.g. I can take the request metadata, lookup in my system whatmydatastorescheme://podcast/1234
is, get its title, description, presenter name, audio stream URL, etc and I can fill out aMediaItem
with that information.However this approach seems somewhat naive and could balloon out a bit when it comes to supporting a wide variety of content types as simple as it is initially. I encountered a roadblock here when it comes to live radio streams, as the
MediaItem
is immutable and I have a need to hit another part of my API at scheduled times in order to update certain parts about the metadata (i.e. what radio program is currently airing, who is presenting, etc). This lead me down the path of looking more at the integration with ExoPlayer and creating custom media sources.I've been attempting to set this up for the last few days with limited success and with some uncertainty over whether I'm using things in the right way.
The first problem I'm tackling is loading simple, on demand content with unchanging metadata (like the podcast example above). I've looked at both
MediaSource
factories andDataSource
factories for achieving this (particularly theResolvingDataSource
). There's a few different roadblocks I've run into with trying each of these approaches:DefaultMediaSourceFactory
with aResolvingDataSource
doesn't work to resolve my content before creating a media source as the media sources are created before the data source is used, theDefaultMediaSourceFactory
also aborts if the local configuration of theMediaItem
is null, which it is for me at this stage since theRequestMetadata
still needs to be resolved.RequestMetadata
into the local configuration, as the type of the media is still unknown at this point, so theDefaultMediaSourceFactory
wouldn't be able to correctly select the rightMediaSource
and would just fall through to the defaultProgressiveMediaSource
.CompositeMediaSource
I am able to set up a loader to resolve my internal URI to an actualMediaItem
with local configuration and metadata, I can then pass this toDefaultMediaSourceFactory
to get aMediaSource
which I can prepare as a child of myCompositeMediaSource
. However, I'm not certain if this is an ideal approach (using a media source factory inside another media source), I've seen a question asked about this without really getting an answer on it specifically (here: MediaSourceFactory for different content types combined with the dynamic stream links androidx/media#17)CompositeMediaSource
approach I can get the audio content playing but the metadata doesn't seem to update. From tracing through the code execution it seems like the block that builds new metadata from incoming playback info (inExoPlayer::updatePlaybackInfo
) isn't getting run due to eithermediaItemTransitioned
being false or thestaticMetadata
being the same across the previous and new playback info objects. My setup is very similar to that seen in the above linked question. InonChildSourceInfoRefreshed
I'm simply callingrefreshSourceInfo
with the new timeline as seen in some built-in composite media sources likeWrappingMediaSource
. I'm unsure why this doesn't carry through and update the metadata in the player.If I can get that working then the next step would be working out what's required (likely in another custom
MediaSource
) to load a stream for playback, then call an API at specific times to fetch the metadata for the next airing program (API has the current and next available with timestamps for the start and end times of each). This feels like it's a job for periods on a timeline? But the mechanism through which to make those schedules API calls and surface the metadata is still unclear to me.The documentation doesn't really have much info in it for worked examples on customized Media Sources, and resolving media lazily from an internal API seems to be a common-ish question just with different nuances. I read through another example of this here: #5883 though it still leaves some questions unanswered (such as my questions above on the use of a factory inside a media source, or the issue with metadata now flowing through from the added child source to the player.
If I could get some guidance on these questions or if this is completely the wrong direction some guidance of what the right direction is, then that would be much appreciated.
The text was updated successfully, but these errors were encountered: