Java 类com.google.android.exoplayer2.source.dash.DefaultDashChunkSource 实例源码

项目:react-native-videoplayer    文件:ReactExoplayerView.java   
private MediaSource buildMediaSource(Uri uri, String overrideExtension) {
    int type = Util.inferContentType(!TextUtils.isEmpty(overrideExtension) ? "." + overrideExtension
            : uri.getLastPathSegment());
    switch (type) {
        case C.TYPE_SS:
            return new SsMediaSource(uri, buildDataSourceFactory(false),
                    new DefaultSsChunkSource.Factory(mediaDataSourceFactory), mainHandler, null);
        case C.TYPE_DASH:
            return new DashMediaSource(uri, buildDataSourceFactory(false),
                    new DefaultDashChunkSource.Factory(mediaDataSourceFactory), mainHandler, null);
        case C.TYPE_HLS:
            return new HlsMediaSource(uri, mediaDataSourceFactory, mainHandler, null);
        case C.TYPE_OTHER:
            return new ExtractorMediaSource(uri, mediaDataSourceFactory, new DefaultExtractorsFactory(),
                    mainHandler, null);
        default: {
            throw new IllegalStateException("Unsupported type: " + type);
        }
    }
}
项目:ExoPlayer-Offline    文件:PlayerActivity.java   
private MediaSource buildMediaSource(Uri uri, String overrideExtension) {
    int type = Util.inferContentType(!TextUtils.isEmpty(overrideExtension) ? "." + overrideExtension
            : uri.getLastPathSegment());
    switch (type) {
        case C.TYPE_SS:
            return new SsMediaSource(uri, buildDataSourceFactory(false),
                    new DefaultSsChunkSource.Factory(mediaDataSourceFactory), mainHandler, eventLogger);
        case C.TYPE_DASH:
            return new DashMediaSource(uri, buildDataSourceFactory(false),
                    new DefaultDashChunkSource.Factory(mediaDataSourceFactory), mainHandler, eventLogger);
        case C.TYPE_HLS:
            return new HlsMediaSource(uri, mediaDataSourceFactory, mainHandler, eventLogger);
        case C.TYPE_OTHER:
            return new ExtractorMediaSource(uri, mediaDataSourceFactory, new DefaultExtractorsFactory(),
                    mainHandler, eventLogger);
        default: {
            throw new IllegalStateException("Unsupported type: " + type);
        }
    }
}
项目:QSVideoPlayer    文件:ExoMedia.java   
private MediaSource buildMediaSource(Context context, Uri uri) {
    int type = getUrlType(uri.toString());
    switch (type) {
        case C.TYPE_SS:
            return new SsMediaSource(uri, new DefaultDataSourceFactory(context, null,
                    new DefaultHttpDataSourceFactory(USER_AGENT, null)),
                    new DefaultSsChunkSource.Factory(new DefaultDataSourceFactory(context, BANDWIDTH_METER,
                            new DefaultHttpDataSourceFactory(USER_AGENT, BANDWIDTH_METER))), mainThreadHandler, null);
        case C.TYPE_DASH:
            return new DashMediaSource(uri, new DefaultDataSourceFactory(context, null,
                    new DefaultHttpDataSourceFactory(USER_AGENT, null)),
                    new DefaultDashChunkSource.Factory(new DefaultDataSourceFactory(context, BANDWIDTH_METER,
                            new DefaultHttpDataSourceFactory(USER_AGENT, BANDWIDTH_METER))), mainThreadHandler, null);
        case C.TYPE_HLS:
            return new HlsMediaSource(uri, new DefaultDataSourceFactory(context, BANDWIDTH_METER,
                    new DefaultHttpDataSourceFactory(USER_AGENT, BANDWIDTH_METER)), mainThreadHandler, null);
        case C.TYPE_OTHER:
            return new ExtractorMediaSource(uri, new DefaultDataSourceFactory(context, BANDWIDTH_METER,
                    new DefaultHttpDataSourceFactory(USER_AGENT, BANDWIDTH_METER)), new DefaultExtractorsFactory(),
                    mainThreadHandler, null);
        default: {
            throw new IllegalStateException("Unsupported type: " + type);
        }
    }
}
项目:chaosflix-leanback    文件:PlayerActivity.java   
private MediaSource buildMediaSource(Uri uri, String overrideExtension) {
    DataSource.Factory mediaDataSourceFactory = buildDataSourceFactory(true);
    int type = TextUtils.isEmpty(overrideExtension) ? Util.inferContentType(uri)
            : Util.inferContentType("." + overrideExtension);
    switch (type) {
        case C.TYPE_SS:
            return new SsMediaSource(uri, buildDataSourceFactory(false),
                    new DefaultSsChunkSource.Factory(mediaDataSourceFactory), mainHandler, null);
        case C.TYPE_DASH:
            return new DashMediaSource(uri, buildDataSourceFactory(false),
                    new DefaultDashChunkSource.Factory(mediaDataSourceFactory), mainHandler, null);
        case C.TYPE_HLS:
            return new HlsMediaSource(uri, mediaDataSourceFactory, mainHandler, null);
        case C.TYPE_OTHER:
            return new ExtractorMediaSource(uri, mediaDataSourceFactory, new DefaultExtractorsFactory(),
                    mainHandler, null);
        default: {
            throw new IllegalStateException("Unsupported type: " + type);
        }
    }
}
项目:chaosflix    文件:ExoPlayerFragment.java   
private MediaSource buildMediaSource(Uri uri, String overrideExtension) {
    DataSource.Factory mediaDataSourceFactory = buildDataSourceFactory(true);
    int type = TextUtils.isEmpty(overrideExtension) ? Util.inferContentType(uri)
            : Util.inferContentType("." + overrideExtension);
    switch (type) {
        case C.TYPE_SS:
            return new SsMediaSource(uri, buildDataSourceFactory(false),
                    new DefaultSsChunkSource.Factory(mediaDataSourceFactory), mainHandler, null);
        case C.TYPE_DASH:
            return new DashMediaSource(uri, buildDataSourceFactory(false),
                    new DefaultDashChunkSource.Factory(mediaDataSourceFactory), mainHandler, null);
        case C.TYPE_HLS:
            return new HlsMediaSource(uri, mediaDataSourceFactory, mainHandler, null);
        case C.TYPE_OTHER:
            return new ExtractorMediaSource(uri, mediaDataSourceFactory, new DefaultExtractorsFactory(),
                    mainHandler, null);
        default: {
            throw new IllegalStateException("Unsupported type: " + type);
        }
    }
}
项目:chaosflix    文件:PlayerActivity.java   
private MediaSource buildMediaSource(Uri uri, String overrideExtension) {
    DataSource.Factory mediaDataSourceFactory = buildDataSourceFactory(true);
    int type = TextUtils.isEmpty(overrideExtension) ? Util.inferContentType(uri)
            : Util.inferContentType("." + overrideExtension);
    switch (type) {
        case C.TYPE_SS:
            return new SsMediaSource(uri, buildDataSourceFactory(false),
                    new DefaultSsChunkSource.Factory(mediaDataSourceFactory), mainHandler, null);
        case C.TYPE_DASH:
            return new DashMediaSource(uri, buildDataSourceFactory(false),
                    new DefaultDashChunkSource.Factory(mediaDataSourceFactory), mainHandler, null);
        case C.TYPE_HLS:
            return new HlsMediaSource(uri, mediaDataSourceFactory, mainHandler, null);
        case C.TYPE_OTHER:
            return new ExtractorMediaSource(uri, mediaDataSourceFactory, new DefaultExtractorsFactory(),
                    mainHandler, null);
        default: {
            throw new IllegalStateException("Unsupported type: " + type);
        }
    }
}
项目:PreviewSeekBar    文件:ExoPlayerMediaSourceBuilder.java   
public MediaSource getMediaSource(boolean preview) {
    switch (streamType) {
        case C.TYPE_SS:
            return new SsMediaSource(uri, new DefaultDataSourceFactory(context, null,
                    getHttpDataSourceFactory(preview)),
                    new DefaultSsChunkSource.Factory(getDataSourceFactory(preview)),
                    mainHandler, null);
        case C.TYPE_DASH:
            return new DashMediaSource(uri,
                    new DefaultDataSourceFactory(context, null,
                            getHttpDataSourceFactory(preview)),
                    new DefaultDashChunkSource.Factory(getDataSourceFactory(preview)),
                    mainHandler, null);
        case C.TYPE_HLS:
            return new HlsMediaSource(uri, getDataSourceFactory(preview), mainHandler, null);
        case C.TYPE_OTHER:
            return new ExtractorMediaSource(uri, getDataSourceFactory(preview),
                    new DefaultExtractorsFactory(), mainHandler, null);
        default: {
            throw new IllegalStateException("Unsupported type: " + streamType);
        }
    }
}
项目:PreviewSeekBar-master    文件:ExoPlayerMediaSourceBuilder.java   
public MediaSource getMediaSource(boolean preview) {
    switch (streamType) {
        case C.TYPE_SS:
            return new SsMediaSource(uri, new DefaultDataSourceFactory(context, null,
                    getHttpDataSourceFactory(preview)),
                    new DefaultSsChunkSource.Factory(getDataSourceFactory(preview)),
                    mainHandler, null);
        case C.TYPE_DASH:
            return new DashMediaSource(uri,
                    new DefaultDataSourceFactory(context, null,
                            getHttpDataSourceFactory(preview)),
                    new DefaultDashChunkSource.Factory(getDataSourceFactory(preview)),
                    mainHandler, null);
        case C.TYPE_HLS:
            return new HlsMediaSource(uri, getDataSourceFactory(preview), mainHandler, null);
        case C.TYPE_OTHER:
            return new ExtractorMediaSource(uri, getDataSourceFactory(preview),
                    new DefaultExtractorsFactory(), mainHandler, null);
        default: {
            throw new IllegalStateException("Unsupported type: " + streamType);
        }
    }
}
项目:TigerVideo    文件:VideoExoPlayer.java   
private MediaSource buildMediaSource(Uri uri, String overrideExtension) {

        int type = Util.inferContentType(!TextUtils.isEmpty(overrideExtension) ? "." + overrideExtension
                : uri.getLastPathSegment());
        switch (type) {
            case C.TYPE_SS:
                return new SsMediaSource(uri, buildDataSourceFactory(false),
                        new DefaultSsChunkSource.Factory(mMediaDataSourceFactory), mMainHandler, mEventLogger);
            case C.TYPE_DASH:
                return new DashMediaSource(uri, buildDataSourceFactory(false),
                        new DefaultDashChunkSource.Factory(mMediaDataSourceFactory), mMainHandler, mEventLogger);
            case C.TYPE_HLS:
                return new HlsMediaSource(uri, mMediaDataSourceFactory, mMainHandler, mEventLogger);
            case C.TYPE_OTHER:
                return new ExtractorMediaSource(uri, mMediaDataSourceFactory, new DefaultExtractorsFactory(),
                        mMainHandler, mEventLogger);
            default: {
                throw new IllegalStateException("Unsupported type: " + type);
            }
        }
    }
项目:ExoPlayerVideoView    文件:ExoVideoView.java   
private MediaSource buildMediaSource(Uri uri, String overrideExtension) {
    int type = Util.inferContentType(!TextUtils.isEmpty(overrideExtension) ? "." + overrideExtension
            : uri.getLastPathSegment());
    switch (type) {
        case C.TYPE_SS:
            return new SsMediaSource(uri, buildDataSourceFactory(false),
                    new DefaultSsChunkSource.Factory(mediaDataSourceFactory), mainHandler, eventLogger);
        case C.TYPE_DASH:
            return new DashMediaSource(uri, buildDataSourceFactory(false),
                    new DefaultDashChunkSource.Factory(mediaDataSourceFactory), mainHandler, eventLogger);
        case C.TYPE_HLS:
            return new HlsMediaSource(uri, mediaDataSourceFactory, mainHandler, eventLogger);
        case C.TYPE_OTHER:
            return new ExtractorMediaSource(uri, mediaDataSourceFactory, new DefaultExtractorsFactory(),
                    mainHandler, eventLogger);
        default: {
            throw new IllegalStateException("Unsupported type: " + type);
        }
    }
}
项目:K-Sonic    文件:KExoMediaPlayer.java   
private MediaSource buildMediaSource(Uri uri, String overrideExtension) {
    int type = Util.inferContentType(!TextUtils.isEmpty(overrideExtension) ? "." + overrideExtension
            : uri.getLastPathSegment());
    switch (type) {
        case C.TYPE_SS:
            return new SsMediaSource(uri, new DefaultDataSourceFactory(context, userAgent),
                    new DefaultSsChunkSource.Factory(mediaDataSourceFactory), mainHandler, eventLogger);
        case C.TYPE_DASH:
            return new DashMediaSource(uri, new DefaultDataSourceFactory(context, userAgent),
                    new DefaultDashChunkSource.Factory(mediaDataSourceFactory), mainHandler, eventLogger);
        case C.TYPE_HLS:
            return new HlsMediaSource(uri, mediaDataSourceFactory, mainHandler, eventLogger);
        case C.TYPE_OTHER:
            return new ExtractorMediaSource(uri, mediaDataSourceFactory, new DefaultExtractorsFactory(),
                    mainHandler, eventLogger);
        default: {
            throw new IllegalStateException("Unsupported type: " + type);
        }
    }
}
项目:cpe-manifest-android-experience    文件:ECVideoViewFragment.java   
private MediaSource buildMediaSource(Uri uri) {
    int type = Util.inferContentType(uri.getLastPathSegment());
    switch (type) {
        case C.TYPE_SS:
            return new SsMediaSource(uri, buildDataSourceFactory(false),
                    new DefaultSsChunkSource.Factory(mediaDataSourceFactory), new Handler(), null);
        case C.TYPE_DASH:
            return new DashMediaSource(uri, buildDataSourceFactory(false),
                    new DefaultDashChunkSource.Factory(mediaDataSourceFactory), new Handler(), null);
        case C.TYPE_HLS:
            return new HlsMediaSource(uri, mediaDataSourceFactory, new Handler(), null);
        case C.TYPE_OTHER:
            return new ExtractorMediaSource(uri, mediaDataSourceFactory, new DefaultExtractorsFactory(),
                    new Handler(), null);
        default: {
            throw new IllegalStateException("Unsupported type: " + type);
        }
    }
}
项目:cpe-manifest-android-experience    文件:StartupActivity.java   
private MediaSource buildMediaSource(Uri uri) {
    int type = Util.inferContentType(uri.getLastPathSegment());
    switch (type) {
        case C.TYPE_SS:
            return new SsMediaSource(uri, buildDataSourceFactory(false),
                    new DefaultSsChunkSource.Factory(mediaDataSourceFactory), new Handler(), null);
        case C.TYPE_DASH:
            return new DashMediaSource(uri, buildDataSourceFactory(false),
                    new DefaultDashChunkSource.Factory(mediaDataSourceFactory), new Handler(), null);
        case C.TYPE_HLS:
            return new HlsMediaSource(uri, mediaDataSourceFactory, new Handler(), null);
        case C.TYPE_OTHER:
            return new ExtractorMediaSource(uri, mediaDataSourceFactory, new DefaultExtractorsFactory(),
                    new Handler(), null);
        default: {
            throw new IllegalStateException("Unsupported type: " + type);
        }
    }
}
项目:videoPickPlayer    文件:CustomExoPlayerView.java   
private MediaSource buildMediaSource(Uri uri, String overrideExtension) {
    int type = Util.inferContentType(!TextUtils.isEmpty(overrideExtension) ? "." + overrideExtension
            : uri.getLastPathSegment());
    switch (type) {
        case C.TYPE_SS:
            return new SsMediaSource(uri, buildDataSourceFactory(false),
                    new DefaultSsChunkSource.Factory(mediaDataSourceFactory), mainHandler, null);
        case C.TYPE_DASH:
            return new DashMediaSource(uri, buildDataSourceFactory(false),
                    new DefaultDashChunkSource.Factory(mediaDataSourceFactory), mainHandler, null);
        case C.TYPE_HLS:
            return new HlsMediaSource(uri, mediaDataSourceFactory, mainHandler, null);
        case C.TYPE_OTHER:
            return new ExtractorMediaSource(uri, mediaDataSourceFactory, new DefaultExtractorsFactory(),
                    mainHandler, null);
        default: {
            throw new IllegalStateException("Unsupported type: " + type);
        }
    }
}
项目:Komica    文件:PlayerActivity.java   
private MediaSource buildMediaSource(Uri uri, String overrideExtension) {
  int type = Util.inferContentType(!TextUtils.isEmpty(overrideExtension) ? "." + overrideExtension
      : uri.getLastPathSegment());
  switch (type) {
    case C.TYPE_SS:
      return new SsMediaSource(uri, buildDataSourceFactory(false),
          new DefaultSsChunkSource.Factory(mediaDataSourceFactory), mainHandler, eventLogger);
    case C.TYPE_DASH:
      return new DashMediaSource(uri, buildDataSourceFactory(false),
          new DefaultDashChunkSource.Factory(mediaDataSourceFactory), mainHandler, eventLogger);
    case C.TYPE_HLS:
      return new HlsMediaSource(uri, mediaDataSourceFactory, mainHandler, eventLogger);
    case C.TYPE_OTHER:
      return new ExtractorMediaSource(uri, mediaDataSourceFactory, new DefaultExtractorsFactory(),
          mainHandler, eventLogger);
    default: {
      throw new IllegalStateException("Unsupported type: " + type);
    }
  }
}
项目:transistor    文件:PlayerManager.java   
@Override
public MediaSource createMediaSource(
    Uri uri, @Nullable Handler handler, @Nullable MediaSourceEventListener listener) {
  @ContentType int type = Util.inferContentType(uri);
  switch (type) {
    case C.TYPE_DASH:
      return new DashMediaSource.Factory(
              new DefaultDashChunkSource.Factory(mediaDataSourceFactory),
              manifestDataSourceFactory)
          .createMediaSource(uri, handler, listener);
    case C.TYPE_HLS:
      return new HlsMediaSource.Factory(mediaDataSourceFactory)
          .createMediaSource(uri, handler, listener);
    case C.TYPE_OTHER:
      return new ExtractorMediaSource.Factory(mediaDataSourceFactory)
          .createMediaSource(uri, handler, listener);
    case C.TYPE_SS:
    default:
      throw new IllegalStateException("Unsupported type: " + type);
  }
}
项目:transistor    文件:DashTestRunner.java   
@Override
protected MediaSource buildSource(HostActivity host, String userAgent,
    TransferListener<? super DataSource> mediaTransferListener) {
  DataSource.Factory manifestDataSourceFactory = dataSourceFactory != null
      ? dataSourceFactory : new DefaultDataSourceFactory(host, userAgent);
  DataSource.Factory mediaDataSourceFactory = dataSourceFactory != null
      ? dataSourceFactory
      : new DefaultDataSourceFactory(host, userAgent, mediaTransferListener);
  Uri manifestUri = Uri.parse(manifestUrl);
  DefaultDashChunkSource.Factory chunkSourceFactory = new DefaultDashChunkSource.Factory(
      mediaDataSourceFactory);
  return new DashMediaSource.Factory(chunkSourceFactory, manifestDataSourceFactory)
      .setMinLoadableRetryCount(MIN_LOADABLE_RETRY_COUNT)
      .setLivePresentationDelayMs(0)
      .createMediaSource(manifestUri);
}
项目:yjPlay    文件:WholeMediaSource.java   
@Override
public MediaSource initMediaSource(Uri uri) {
    int streamType = VideoPlayUtils.inferContentType(uri);
    switch (streamType) {
        case C.TYPE_SS:
            return new  SsMediaSource.Factory(new DefaultSsChunkSource.Factory(getDataSource()), new DefaultDataSourceFactory(context, null,
                    getDataSource()))
                    .setMinLoadableRetryCount(5)
                    .createMediaSource(uri,mainHandler,sourceEventListener);
        case C.TYPE_DASH:
            return new DashMediaSource.Factory(new DefaultDashChunkSource.Factory(getDataSource())
                     ,new DefaultDataSourceFactory(context, null, getDataSource()))
                     .setMinLoadableRetryCount(5)
                     .createMediaSource(uri, mainHandler, sourceEventListener);
        case C.TYPE_OTHER:
            return new  ExtractorMediaSource.Factory( getDataSource())
                     .setExtractorsFactory( new DefaultExtractorsFactory())
                    .setMinLoadableRetryCount(5)
                    .setCustomCacheKey(uri.getPath())
                    .createMediaSource(uri,mainHandler,null);
        case C.TYPE_HLS:
            return new HlsMediaSource.Factory(new DefaultHlsDataSourceFactory( getDataSource()))
                    .setMinLoadableRetryCount(5)
                    .createMediaSource(uri, mainHandler, sourceEventListener);

        default:
            throw new IllegalStateException(":Unsupported type: " + streamType);
    }
}
项目:ExoPlayer-Offline    文件:DashTest.java   
@Override
protected MediaSource buildSource(HostActivity host, String userAgent,
    TransferListener<? super DataSource> mediaTransferListener) {
  DataSource.Factory manifestDataSourceFactory = new DefaultDataSourceFactory(host, userAgent);
  DataSource.Factory mediaDataSourceFactory = new DefaultDataSourceFactory(host, userAgent,
      mediaTransferListener);
  Uri manifestUri = Uri.parse(parameters.manifestUrl);
  DefaultDashChunkSource.Factory chunkSourceFactory = new DefaultDashChunkSource.Factory(
      mediaDataSourceFactory);
  return new DashMediaSource(manifestUri, manifestDataSourceFactory, chunkSourceFactory,
      MIN_LOADABLE_RETRY_COUNT, 0 /* livePresentationDelayMs */, null, null);
}
项目:exoplayer-intro    文件:PlayerActivity.java   
private MediaSource buildMediaSource(Uri uri) {
  DataSource.Factory manifestDataSourceFactory = new DefaultHttpDataSourceFactory("ua");
  DashChunkSource.Factory dashChunkSourceFactory = new DefaultDashChunkSource.Factory(
      new DefaultHttpDataSourceFactory("ua", BANDWIDTH_METER));
  return new DashMediaSource.Factory(dashChunkSourceFactory, manifestDataSourceFactory)
      .createMediaSource(uri);
}
项目:exoplayer-intro    文件:PlayerActivity.java   
private MediaSource buildMediaSource(Uri uri) {
  DataSource.Factory manifestDataSourceFactory = new DefaultHttpDataSourceFactory("ua");
  DashChunkSource.Factory dashChunkSourceFactory = new DefaultDashChunkSource.Factory(
      new DefaultHttpDataSourceFactory("ua", BANDWIDTH_METER));
  return new DashMediaSource.Factory(dashChunkSourceFactory, manifestDataSourceFactory)
      .createMediaSource(uri);
}
项目:exoplayer-intro    文件:PlayerActivity.java   
private MediaSource buildMediaSource(Uri uri) {
  DashChunkSource.Factory dashChunkSourceFactory = new DefaultDashChunkSource.Factory(
      new DefaultHttpDataSourceFactory("ua", BANDWIDTH_METER));
  DataSource.Factory manifestDataSourceFactory = new DefaultHttpDataSourceFactory("ua");
  return new DashMediaSource.Factory(dashChunkSourceFactory, manifestDataSourceFactory).
      createMediaSource(uri);
}
项目:GSYVideoPlayer    文件:IjkExo2MediaPlayer.java   
private MediaSource getMediaSource(boolean preview) {
    Uri contentUri = Uri.parse(mDataSource);
    int contentType = inferContentType(mDataSource);
    switch (contentType) {
        case C.TYPE_SS:
            return new SsMediaSource(contentUri, new DefaultDataSourceFactory(mAppContext, null,
                    getHttpDataSourceFactory(preview)),
                    new DefaultSsChunkSource.Factory(getDataSourceFactory(preview)),
                    mainHandler, null);
        case C.TYPE_DASH:
            return new DashMediaSource(contentUri,
                    new DefaultDataSourceFactory(mAppContext, null,
                            getHttpDataSourceFactory(preview)),
                    new DefaultDashChunkSource.Factory(getDataSourceFactory(preview)),
                    mainHandler, null);
        case C.TYPE_HLS:
            return new HlsMediaSource(contentUri, getDataSourceFactory(preview), mainHandler, null);
        case TYPE_RTMP:
            RtmpDataSourceFactory rtmpDataSourceFactory = new RtmpDataSourceFactory(null);
            return new ExtractorMediaSource(contentUri, rtmpDataSourceFactory,
                    new DefaultExtractorsFactory(), mainHandler, null);
        case C.TYPE_OTHER:
        default:
            return new ExtractorMediaSource(contentUri, getDataSourceFactory(preview),
                    new DefaultExtractorsFactory(), mainHandler, null);
    }
}
项目:no-player    文件:MediaSourceFactory.java   
public MediaSource create(ContentType contentType,
                          Uri uri,
                          ExtractorMediaSource.EventListener eventListener,
                          AdaptiveMediaSourceEventListener mediaSourceEventListener) {
    switch (contentType) {
        case HLS:
            return new HlsMediaSource(
                    uri,
                    mediaDataSourceFactory,
                    handler,
                    mediaSourceEventListener
            );
        case H264:
            DefaultExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
            return new ExtractorMediaSource(
                    uri,
                    mediaDataSourceFactory,
                    extractorsFactory,
                    handler,
                    eventListener
            );
        case DASH:
            DefaultDashChunkSource.Factory chunkSourceFactory = new DefaultDashChunkSource.Factory(mediaDataSourceFactory);
            return new DashMediaSource(
                    uri,
                    mediaDataSourceFactory,
                    chunkSourceFactory,
                    handler,
                    mediaSourceEventListener
            );
        default:
            throw new UnsupportedOperationException("Content type: " + contentType + " is not supported.");
    }
}
项目:MDVideo    文件:PlayerActivityV2.java   
private MediaSource buildMediaSource(Uri uri, String overrideExtension) {
    int type = Util.inferContentType(!TextUtils.isEmpty(overrideExtension) ? "." + overrideExtension
            : uri.getLastPathSegment());
    switch (type) {
        case TYPE_SS:
            return new SsMediaSource(uri, buildDataSourceFactory(false),
                    new DefaultSsChunkSource.Factory(mediaDataSourceFactory), mainHandler, eventLogger);
        case C.TYPE_DASH:
            return new DashMediaSource(uri, buildDataSourceFactory(false),
                    new DefaultDashChunkSource.Factory(mediaDataSourceFactory), mainHandler, eventLogger);
        case C.TYPE_HLS:
            return new HlsMediaSource(uri, mediaDataSourceFactory, mainHandler, eventLogger);
        case C.TYPE_OTHER:
            MediaSource mediaSource = new ExtractorMediaSource(uri, mediaDataSourceFactory, new DefaultExtractorsFactory(),
                    mainHandler, eventLogger);

            if (mSubtitleUri != null) {
                Log.d(TAG, "====加载字幕====buildMediaSource: ");
                return TextSubtitle(mSubtitleUri, mediaSource);
            } else {
                return mediaSource;
            }
        default: {
            throw new IllegalStateException("Unsupported type: " + type);
        }
    }
}
项目:ExoMedia    文件:DashMediaSourceBuilder.java   
@NonNull
@Override
public MediaSource build(@NonNull Context context, @NonNull Uri uri, @NonNull String userAgent, @NonNull Handler handler, @Nullable TransferListener<? super DataSource> transferListener) {
    DataSource.Factory dataSourceFactory = buildDataSourceFactory(context, userAgent, null);
    DataSource.Factory meteredDataSourceFactory = buildDataSourceFactory(context, userAgent, transferListener);

    return new DashMediaSource(uri, dataSourceFactory, new DefaultDashChunkSource.Factory(meteredDataSourceFactory), handler, null);
}
项目:transistor    文件:PlayerActivity.java   
private MediaSource buildMediaSource(
    Uri uri,
    String overrideExtension,
    @Nullable Handler handler,
    @Nullable MediaSourceEventListener listener) {
  @ContentType int type = TextUtils.isEmpty(overrideExtension) ? Util.inferContentType(uri)
      : Util.inferContentType("." + overrideExtension);
  switch (type) {
    case C.TYPE_DASH:
      return new DashMediaSource.Factory(
              new DefaultDashChunkSource.Factory(mediaDataSourceFactory),
              buildDataSourceFactory(false))
          .createMediaSource(uri, handler, listener);
    case C.TYPE_SS:
      return new SsMediaSource.Factory(
              new DefaultSsChunkSource.Factory(mediaDataSourceFactory),
              buildDataSourceFactory(false))
          .createMediaSource(uri, handler, listener);
    case C.TYPE_HLS:
      return new HlsMediaSource.Factory(mediaDataSourceFactory)
          .createMediaSource(uri, handler, listener);
    case C.TYPE_OTHER:
      return new ExtractorMediaSource.Factory(mediaDataSourceFactory)
          .createMediaSource(uri, handler, listener);
    default: {
      throw new IllegalStateException("Unsupported type: " + type);
    }
  }
}
项目:CumulusTV    文件:MediaSourceFactory.java   
public static MediaSource getMediaSourceFor(Context context, Uri mediaUri,
        String overrideExtension) {
    // Measures bandwidth during playback. Can be null if not required.
    DataSource.Factory mediaDataSourceFactory = buildDataSourceFactory(context, true);

    int type = Util.inferContentType(!TextUtils.isEmpty(overrideExtension) ?
            "." + overrideExtension
            : mediaUri.getLastPathSegment());
    Handler mainHandler = new Handler();
    switch (type) {
        case C.TYPE_SS:
            return new SsMediaSource(mediaUri, buildDataSourceFactory(context, false),
                    new DefaultSsChunkSource.Factory(mediaDataSourceFactory),
                    mainHandler, null);
        case C.TYPE_DASH:
            return new DashMediaSource(mediaUri, buildDataSourceFactory(context, false),
                    new DefaultDashChunkSource.Factory(mediaDataSourceFactory), mainHandler,
                    null);
        case C.TYPE_HLS:
            return new HlsMediaSource(mediaUri, mediaDataSourceFactory, mainHandler,
                    null);
        case C.TYPE_OTHER:
            return new ExtractorMediaSource(mediaUri, mediaDataSourceFactory,
                    new DefaultExtractorsFactory(), mainHandler, null);
        default: {
            throw new NotMediaException("Unsupported type: " + type);
        }
    }
}
项目:Slide    文件:MediaVideoView.java   
public void openVideo() {
    if ((uri == null) && dashURL == null) {
        LogUtil.v("Cannot open video, uri or surface is null number " + number);
        return;
    }
    animate().alpha(1);

    // Tell the music playback service to pause

    try {

        attachMediaControls();
        setOnBufferUpdateListener(bufferingUpdateListener);
        setOnPreparedListener(preparedListener);
        setOnErrorListener(errorListener);
        setKeepScreenOn(true);
        setOnVideoSizedChangedListener(videoSizeChangedListener);

        DataSource.Factory dataSourceFactory =
                new CacheDataSourceFactory(getContext(), 100 * 1024 * 1024, 5 * 1024 * 1024);

        if (dashURL == null) {
            setVideoURI(uri, null);
        } else {

            DashMediaSource video =
                    new DashMediaSource(Uri.parse(dashURL.toString()), dataSourceFactory,
                            new DefaultDashChunkSource.Factory(dataSourceFactory), null, null);
            setVideoURI(uri, video);
        }
        audioFocusHelper.abandonFocus();

        LogUtil.v("Preparing media player.");
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
}
项目:B4A_ExoPlayer    文件:SimpleExoPlayerWrapper.java   
/**
 * Creates a Dash (Dynamic Adaptive Streaming over Http) source.
 */
public Object CreateDashSource (String Uri) {
    return new DashMediaSource(android.net.Uri.parse(Uri), createDefaultDataFactory(), new DefaultDashChunkSource.Factory(createDefaultDataFactory()), null, null);
}
项目:ExoPlayer-with-MediaControls    文件:MainActivity.java   
private void initDashPlayer(String dashUrl) {




    MediaSource sampleSource =
        new DashMediaSource(Uri.parse(dashUrl), new DefaultDataSourceFactory(this, userAgent),
            new DefaultDashChunkSource.Factory(dataSourceFactory), handler,
            this);

    initExoPlayer(sampleSource);
  }