I don't know the protocol of a video,how can i play the video with exo player
Thanks developers of ExoPlayer!
I have a question now, i hava a url of a video,but i don't know protocol of the video,how can i play the video with ExoPlayer?
I had seen source of ExoPlayer.
private RendererBuilder getRendererBuilder() { String userAgent = Util.getUserAgent(this, "ExoPlayerDemo"); switch (contentType) { case Util.TYPE_SS: return new SmoothStreamingRendererBuilder(this, userAgent, contentUri.toString(), new SmoothStreamingTestMediaDrmCallback()); case Util.TYPE_DASH: return new DashRendererBuilder(this, userAgent, contentUri.toString(), new WidevineTestMediaDrmCallback(contentId, provider)); case Util.TYPE_HLS: return new HlsRendererBuilder(this, userAgent, contentUri.toString()); case Util.TYPE_OTHER: return new ExtractorRendererBuilder(this, userAgent, contentUri); default: throw new IllegalStateException("Unsupported type: " + contentType); } }
Ut supra,I don't know the 'contentType' of a video,but,how can i play the video with ExoPlayer?
For example, this url " http://pl.youku.com/playlist/m3u8?vid=430726292&type=hd2&ts=1473754224&ep=ciaTGU6IUswC4SbXgT8bb32wc3IIXPoJ9hiHh9BrAtQkTey2&sid=0473754224589128ab757&token=0549&ctype=12&ev=1&oip=2067486600".
It is m3u8 of the url container format.If i don't know it,How can i choose the renderer?
Depends on the case. As you correctly state, in this case it is an m3u8, which maps to HLS.
For manifest based formats (HLS, SS, DASH), if the file has an extension, you can use that to try the corresponding RendererBuilder(.m3u8, .ism, mpd; note there are more alternative extensions).
In the case of standalone files, like mp4, flv, mp3, etc. the best way is to sniff them with the extractors and see which one returns true (this is already done by the ExtractorSampleSource, you don't have to do it yourself). Ultimately is a matter of content, unfortunately, so the ground truth is what the file contains: The url you provide is m3u8 media playlist (it is not strictly HLS, but it's the same renderer builder). You will need to take a look yourself. It would not be hard to build a "universal sniffer", I think.