mirror of
https://github.com/samsonjs/media.git
synced 2026-03-27 09:45:47 +00:00
| .. | ||
| src/main | ||
| build.gradle | ||
| README.md | ||
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);
}
}
}