-
Notifications
You must be signed in to change notification settings - Fork 476
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 #258
Comments
I think you're hitting a couple of different existing issues/feature requests:
To specifically answer some of the parts of your post:
I think this would be resolved by #33? (without needing a custom media source)
If you want to use
This reflects a limitation of
This is sort of intended - customising |
Is there an expected resolution timeframe for #33? I can populate my MediaItem in |
I'm afraid we don't have a timeline for this. Picking up another comment you made on google/ExoPlayer#11031:
This documentation is a little stale, apologies: |
So, in the absence of #33 and #3165, is there any other mechanism for sideloading the pushing of metadata updates to the player that doesn't get too fiddly? A way to manually trigger Or at this stage does this need to be handled separately to Media3 (i.e. updating the app player UI and OS Media Notification without reference to the |
I've just fixed a small mistake in my comment above, where I originally said:
This missed the fact that
I have not tested this, but you may be able to use For consistency, you will need to ensure that you also change the result of One thing to note: When you override |
Thank you, I'll try that approach in the next week and report back |
The `@CallSuper` annotation should help catch cases where subclasses are calling `delegate.addListener` instead of `super.addListener` but it will also (unintentionally) prevent subclasses from either completely no-opping the listener registration, or implementing it themselves in a very custom way. I think that's probably OK, since these cases are probably unusual, and they should be able to suppress the warning/error. Issue: #258 #minor-release PiperOrigin-RevId: 513848402
The `@CallSuper` annotation should help catch cases where subclasses are calling `delegate.addListener` instead of `super.addListener` but it will also (unintentionally) prevent subclasses from either completely no-opping the listener registration, or implementing it themselves in a very custom way. I think that's probably OK, since these cases are probably unusual, and they should be able to suppress the warning/error. Issue: androidx/media#258 #minor-release PiperOrigin-RevId: 513848402
This is now a much more 'internal' component, and there's no way to register one directly on a `Player` instance. Issue: androidx/media#258 #minor-release PiperOrigin-RevId: 513849776
This is now a much more 'internal' component, and there's no way to register one directly on a `Player` instance. Issue: androidx/media#258 #minor-release PiperOrigin-RevId: 513849776 (cherry picked from commit abcb806)
Closing because I think the question has been answered and the pending feature requests are tracked elsewhere. |
The `@CallSuper` annotation should help catch cases where subclasses are calling `delegate.addListener` instead of `super.addListener` but it will also (unintentionally) prevent subclasses from either completely no-opping the listener registration, or implementing it themselves in a very custom way. I think that's probably OK, since these cases are probably unusual, and they should be able to suppress the warning/error. Issue: #258 #minor-release PiperOrigin-RevId: 513848402 (cherry picked from commit 5d23a92)
The `@CallSuper` annotation should help catch cases where subclasses are calling `delegate.addListener` instead of `super.addListener` but it will also (unintentionally) prevent subclasses from either completely no-opping the listener registration, or implementing it themselves in a very custom way. I think that's probably OK, since these cases are probably unusual, and they should be able to suppress the warning/error. Issue: androidx/media#258 #minor-release PiperOrigin-RevId: 513848402 (cherry picked from commit af45bed)
I know I said next week in my comment previously but priorities ended up shifting a bit and I haven't had much of a chance to look at this. Taking a look now I assume the approach is to override the I assume that since the linked issue #246 is still open there is still a need for some additional invalidation in order to force the media notification to pull updated metadata? or forcing the media notification to check for new metadata is currently not possible? |
Yep, this sounds right.
You will want to trigger
Also |
Hey @icbaker, Thanks for the suggestion with the So far it works quite well, but somehow the ICY metadata keeps getting delivered to listers that attach to the I assumed that the Am I getting something wrong here? |
Just to check I'm understanding your problem statement: You're trying to stop ICY metadata from reaching |
@icbaker Yes, totally right. The icy metadata is quite limited and we try to present only the richer information from an external API, but we might need the icy metadata as a trigger, though. So we can't totally block any icy The idea based on your suggestion was, catch |
Thanks - this sounds slightly different to the original question in this thread. Rather than re-opening this issue, would you mind filing a new issue (you can just copy the content from your two comments here), and I'll follow up there. It would also be helpful to include a code snippet showing exactly how you've 'intercepted' the |
I've searched around extensively on this repository, on the ExoPlayer 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:
MediaItem
that uses request metadata to point to one of my internal URIs (something likemydatastorescheme://podcast/{id}
) and the rest is handled opaquely inside the Media code.In Media3 we have 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 #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.MediaSource.Factory
seems like an ideal place for this except that it must immediately return a value.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: google/ExoPlayer#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: