mirror of
https://github.com/androidx/media.git
synced 2025-05-17 12:39:52 +08:00
ExoPlayer RTMP Extension
Description
The RTMP Extension is an DataSource implementation for playing RTMP streaming using Librtmp Client for Android.
Using the extension
When building MediaSource, inject RtmpDataSourceFactory
like this:
private MediaSource buildMediaSource(Uri uri, String overrideExtension) {
int type = TextUtils.isEmpty(overrideExtension) ? Util.inferContentType(uri)
: Util.inferContentType("." + overrideExtension);
switch (type) {
// ... other types cases
case C.TYPE_OTHER:
DataSource.Factory factory = uri.getScheme().equals("rtmp") ? new RtmpDataSourceFactory() : mediaDataSourceFactory;
return new ExtractorMediaSource(uri, factory, new DefaultExtractorsFactory(), mainHandler, eventLogger);
default: {
throw new IllegalStateException("Unsupported type: " + type);
}
}
}