How to use Custom Manifest parser with MediaItem
With MediaItem I am not able to find a method to set custom parser. Where as setting custom parser is available in MediaSource object.
Is there any way to do this without using MediaSource or overriding DefaultMediaSourceFactory ?
Are you talking about a custom parser for a DASH or HLS manifest? Given each of these only relates to a single type of MediaSource, providing your own MediaSourceFactory is the expected way to do this level of customization: https://exoplayer.dev/media-sources.html#customizing-media-source-creation
@icbaker Thanks for the quick revert. Are you talking about a custom parser for a DASH or HLS manifest? - Yes
I figured it out using MediaSourceFactory, but the only problem is I have to copy entire DefaultMediaSourceFactory to achieve this.
I am just checking if there is any other simple way to do this.. like provide a factory for CustomParser ?
Can you give a bit more detail about why you need to copy all of DefaultMediaSourceFactory?
If you know your content is always HLS or always DASH then you can just use HlsMediaSource.Factory or DashMediaSource.Factory directly - with the caveat that ad insertion, sideloaded subtitles and clipping will not work (because these are implemented by DefaultMediaSourceFactory).
If you need to support a range of streaming protocols, but don't need ad insertion, sideloaded subtitles or clipping then you can implement a MediaSource.Factory that wraps DefaultMediaSourceFactory and delegates all non-HLS/DASH streams to it, while using a couple of internal HlsMediaSource.Factory and DashMediaSource.Factory instances to handle the DASH and HLS streams.
If you need ad insertion, sideloaded subtitles or clipping then currently we don't have a good solution - though we do have some plans to move this functionality into the 'leaf' MediaSource.Factory instances (e.g. HlsMediaSource.Factory), as well as some ideas about allowing you to specify how DefaultMediaSourceFactory should instantiate specific MediaSource.Factory instances. Both of these would help you (the latter would be ideal for you I think), but unfortunately we have no concrete plans to work on either of these at the moment.
Yes, we have mix of both HLS, DASH stream, SSAI streams.
I am trying to solve following use case.
We have a stream which can dolby, 4k and other formats. We also maintain config where we maintain list of models and devices which can get 4k, Dolby.
Now based on the list I can either whitelist or blacklist some of the tracks. This can be done from Backend side as well, but this is not in the scope for us right now.
I am trying to achieve this using FilterableManifest.
After analysing DefaultMediaSourceFactory I found the only place I can set custom FilterableManifest is in getMediaSourceFactory function of DelegateFactoryLoader
Please suggest if there is a better way to do this.
It sounds like you'd be better off using ExoPlayer's track selection logic: https://exoplayer.dev/track-selection.html
This will operate on ExoPlayer's model of the tracks after it's been parsed, so no need to set HLS and DASH specific parsers.
FilterableManifest (if this is what you're referring to) is in the offline package and really only intended to be used as part of downloading streams, so I don't think it's the right tool here if you're trying to do playback rather than downloading.
@icbaker thanks for the suggestion.
I've explored TrackSelection, the problem is I've to handle them from showing in UI also. Also I believe TrackSelection works only after player is Initialised
I want to filter them during the parsing tracks itself so that all extra handling can be avoided.
Closing due to inactivity.