I'm working on creating a custom media player using ExoPlayer (I've previously opened several questions on the same topic, because I'm very new to Android development and it seems like I run into a wall with every line of code I write).
As part of this custom player I would like to download, parse, and handle an XML file that our business produces to define our content. This XML file gives a URL for a network ID (a 4-6 second video advertising the owner of the content), a URL for the content, and an ad tag URL for playing pre-roll and mid-roll ads.
My goal is to pass this XML file as a video source to prepare()
, call setPlayWhenReady(true)
, then have everything play as expected (network ID, content, and ads)
To do this I believe I need to create a custom MediaSource -- however I cannot find any good documentation or tutorials on doing so. The ExoPlayer documentation on MediaSources is practically useless on this case, only describing how to utilize ConcatenatingMediaSource, MergingMediaSource, and LoopingMediaSource to customize the playback of media.
Update
Continuing to research on my own, it's possible what I want may be accomplished with a custom Extractor. When I pass the content to an ExtractorMediaSource I receive the error com.google.android.exoplayer2.source.UnrecognizedInputFormatException: None of the available extractors (MatroskaExtractor, FragmentedMp4Extractor, Mp4Extractor, Mp3Extractor, AdtsExtractor, Ac3Extractor, TsExtractor, FlvExtractor, OggExtractor, PsExtractor, WavExtractor, AmrExtractor) could read the stream.
. This makes me wonder if it's better to have an Extractor parse the XML, pull the content, and pass the data back. I'm not sure yet what the difference is between these two components or which is a better fit, and the documentation is lacking.
View
? IMHO, downloading and parsing the XML should be the responsibility of a repository, or at worst a viewmodel. – CommonsWareMediaPlayer
, throw a video at it, and it just plays like magic -- I want people to be able to instantiate aBFPlayer
, throw a video at it, and it just plays like magic... with the added benefit that it will know how to play our content. Therefore the parsing of this XML file should be the responsibility of the video player, not of the client's app. – stevendesu