2017-04-30 08:58:55 +08:00
..
2017-04-30 08:58:55 +08:00
2017-04-30 08:58:55 +08:00
2017-04-30 08:58:55 +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);
    }
  }
}