-
Notifications
You must be signed in to change notification settings - Fork 405
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
Is there a way to associate a Renderer with a MediaItem? #883
Comments
Stepping back slightly: Would your use-case be served with effects or custom audio processors, rather than needing a whole separate renderer instance for each item (presumably these items are in a playlist?)? I only suggest this because the example you give is about adjusting the volume, which should be possible with effects/processors. Manually creating a separate renderer for each media item sounds a little unusual. To answer what you actually asked: I think @christosts was discussing recently how to access the currently playing |
It's funny you mention processors because that would be the next step beyond this. I need to control each piece of media individually before mixing them down into a single output buffer and sending it off to the audio track for consumption (which, from what I understand, can be achieved via custom audio sinks and processors). The example was just to show that I want to interact with the renderer in some way given the information I receive from the server (the filename). To be extra clear, I could potentially need to do that following:
|
To answer the very specific question asked:
As of version 1.2.0, there are two changes in
With a Timeline and a MediaPeriodId, you can get the
That said, on your overall plans for mixing mp3 files together:
The ability to play multiple videos and audios together, apply visual and audio effects, and preview the result in real-time is something we are working on. But for your immediate needs, you might be able to use Transformer to first mix the audios and produce an intermediate file. cc-ing @Samrobbo for audio processing related information |
Oh interesting. I tried to find the MediaItem relationship on the Timeline and MediaPeriodId in the LoadControl object I set up as they are exposed there but had no luck since onTracksSelected only exposes a Renderer array, not a BaseRenderer. I was hoping to set it in LoadControl as I only really need to set this relationship once during initialization. The tracks will never change, but the entire set of files will as the app is used.
Yes, that was my intention. I tried using several ExoPlayer instances but found that it was too out of sync with one another to get the results I needed.
The goal is to get up to 16 tracks mixed down and played back simultaneously. The average may be less, but that's the most extreme case I'm preparing for. I don't really know what the upper-bound is for simultaneous playback using ExoPlayer, but I rolled my own mixing solution using AudioTrack, MediaCodec, and MediaExtractor and got 12 to work fairly well, only bottlenecked by I/O. I saw that ExoPlayer has a more elaborate solution for loading files so I wanted to get a prototype working using something more established and tested.
I do need the operation to happen in real-time as there will be some manipulation happening during mixing and playback. I will also be working with multiple sets of files coming from my server. As a first step, I intend to tear down the ExoPlayer instance and set it up for each new set of files loaded to the device for simplicity's sake. So, one set may have 5 files while another has 10 and yet another has 16, each being mapped to a renderer for playback and real-time manipulation. |
How are the media items given to player? As a List with Aside:
|
That could be an issue. Would a MergingMediaSource solve this? I'm assuming if this is the case that the MergingMediaSource would have tracks rather than individual MediaItems and I'd need to create an association a different way between the Renderers and the files for which they are responsible. |
You'd need to do the association on track level when using |
I tried to experiment with your suggestion, but it seems I've hit a bit of a snag. I've created a
I'm guessing that I need to override the |
This was just a suggestion that isn't implemented yet :) You probably find that all |
This was already done for the TrackGroup ids in <unknown commit>, but in some scenarios only the Format instances are known and it's helpful to be able to identify where they came from. Issue: #883 #minor-release PiperOrigin-RevId: 604644039
This was already done for the TrackGroup ids in <unknown commit>, but in some scenarios only the Format instances are known and it's helpful to be able to identify where they came from. Issue: androidx/media#883 #minor-release PiperOrigin-RevId: 604644039
We now made the change suggested above and the |
Issue: #883 #minor-release PiperOrigin-RevId: 613970048
Issue: androidx/media#883 #minor-release PiperOrigin-RevId: 613970048
Hey everyone, this is a more conceptual question about exoplayer. I'm trying to understand where I can find the relationship between a media file (e.g. a mp3 file / MediaItem) and the renderer within the code itself.
My use case has me downloading several mp3 files from my server, each with specific file names, and loading them into several renderers, one for each file, for playback. The goal is to be able to access a renderer for a given file--for example: sending a MSG_SET_VOLUME message to a renderer given the filename. I can create the renderers just fine using a custom RenderersFactory, but beyond this I'm having some trouble tracing the relationship between a renderer and the source of its data.
I've looked at TrackSelection and LoadControl, but each have TrackGroups and TrackSelections within their purview, not a direct relationship to a MediaItem. In other words, I don't believe I can tell which file the TrackSelection or TrackGroup is associated with. I've also looked at setting custom metadata for the MediaItems I'm giving my player via setting MediaMetadata on the MediaItem.Builder in the hopes of retrieving it somewhere like LoadControl, but I cannot seem to access the metadata I set, only the ID3 metadata.
For example, here's how I tried to see the metadata I set on a singular MediaItem. I attempted to put the filename as the track title:
Based on the diagram in the glossary, it seems like everything has a one-way relationship when loading from a file and I cannot really walk back up the chain easily.
Any help pointing me in the correct direction would really be appreciated. I'm hoping I missed something obvious.
Thanks.
The text was updated successfully, but these errors were encountered: