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

项目: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);
        }
    }
}
项目:AesExoPlayer    文件:TestPlayerActivity.java   
/**
     * 重载资源
     *
     * @param url
     */
    private void reLoadSourcePlay(String url) {
        Timber.e("重载资源file1---:" + url);
        //重载资源
        videoSource.releaseSource();
        seekBar.setMax(0);
        seekBar.setProgress(0);
        allPlayerTime.setText("00:00");
        ExtractorMediaSource extractorMediaSource =
                new ExtractorMediaSource(Uri.parse(url), aitripFactory,
                        extractorsFactory, null, null);
        player.prepare(extractorMediaSource);
        //设置文字
//        allPlayerTime.setText(TimeUtils.secToTime((int) (player.getDuration() / 1000)));
        //设置总时长
//        seekBar.setMax((int) (player.getDuration() / 100));
        continuePlay();//开始播放
    }
项目:syncplayer    文件:MediaService.java   
public void preparePlayer() {
    MediaSource videoSource = new ExtractorMediaSource(syncplayuri,
            dataSourceFactory, extractorsFactory, null, null);
    mMediaPlayer.prepare(videoSource);
    mSyncPlayClient.setPlayerState(new syncPlayClientInterface.playerDetails() {
        @Override
        public long getPosition() {
            return mMediaPlayer.getCurrentPosition() / 1000L;
        }

        @Override
        public Boolean isPaused() {
            return !mMediaPlayer.getPlayWhenReady();
        }
    });
}
项目: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);
        }
    }
}
项目:BakingApp    文件:StepDetailFragment.java   
private void initializePlayer(Uri videoUri){
    if (mExoPlayer == null){
        TrackSelector trackSelector = new DefaultTrackSelector();
        LoadControl loadControl = new DefaultLoadControl();
        mExoPlayer = ExoPlayerFactory.newSimpleInstance(getContext(), trackSelector, loadControl);
        mExoPlayer.addListener(this);
        mExoPlayer.seekTo(currentPosition);
        mPlayerView.setPlayer(mExoPlayer);
        String userAgent = Util.getUserAgent(getContext(), "Tasty");
        MediaSource mediaSource = new ExtractorMediaSource(videoUri, new DefaultDataSourceFactory(
                getContext(), userAgent), new DefaultExtractorsFactory(), null, null);
        mExoPlayer.prepare(mediaSource);
        if (playWhenReady) mExoPlayer.setPlayWhenReady(true);
        else mExoPlayer.setPlayWhenReady(false);
    }
}
项目: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);
        }
    }
}
项目:Melophile    文件:MediaPlayback21.java   
@Override
public void startPlayer() {
    if(exoPlayer==null){
        exoPlayer =
                ExoPlayerFactory.newSimpleInstance(
                        context, new DefaultTrackSelector(), new DefaultLoadControl());
        exoPlayer.addListener(this);
    }
    exoPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
    DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(
            context, Util.getUserAgent(context, "uamp"), null);
    ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
    MediaSource mediaSource = new ExtractorMediaSource(
            Uri.parse(currentUrl), dataSourceFactory, extractorsFactory, null, null);
    exoPlayer.prepare(mediaSource);
    configPlayer();
}
项目:Cable-Android    文件:VideoPlayer.java   
private void setExoViewSource(@NonNull MasterSecret masterSecret, @NonNull VideoSlide videoSource)
    throws IOException
{
  BandwidthMeter         bandwidthMeter             = new DefaultBandwidthMeter();
  TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter);
  TrackSelector          trackSelector              = new DefaultTrackSelector(videoTrackSelectionFactory);
  LoadControl            loadControl                = new DefaultLoadControl();

  exoPlayer = ExoPlayerFactory.newSimpleInstance(getContext(), trackSelector, loadControl);
  exoView.setPlayer(exoPlayer);

  DefaultDataSourceFactory    defaultDataSourceFactory    = new DefaultDataSourceFactory(getContext(), "GenericUserAgent", null);
  AttachmentDataSourceFactory attachmentDataSourceFactory = new AttachmentDataSourceFactory(getContext(), masterSecret, defaultDataSourceFactory, null);
  ExtractorsFactory           extractorsFactory           = new DefaultExtractorsFactory();

  MediaSource mediaSource = new ExtractorMediaSource(videoSource.getUri(), attachmentDataSourceFactory, extractorsFactory, null, null);

  exoPlayer.prepare(mediaSource);
  exoPlayer.setPlayWhenReady(true);
}
项目:android-arch-components-lifecycle    文件:VideoPlayerComponent.java   
private void initializePlayer() {
    if (player == null) {
        trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
        player = ExoPlayerFactory.newSimpleInstance(context, trackSelector);
        player.addListener(this);
        DefaultDataSourceFactory dataSourceFactory = new DefaultDataSourceFactory(context,
                Util.getUserAgent(context, "testApp"), bandwidthMeter);

        ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
        ExtractorMediaSource videoSource = new ExtractorMediaSource(Uri.parse(videoUrl),
                dataSourceFactory, extractorsFactory, null, null);
        simpleExoPlayerView.setPlayer(player);
        player.setPlayWhenReady(true);

        boolean haveResumePosition = resumeWindow != C.INDEX_UNSET;
        if (haveResumePosition) {
            Log.d(TAG, "Have Resume position true!" + resumePosition);
            player.seekTo(resumeWindow, resumePosition);
        }

        player.prepare(videoSource, !haveResumePosition, false);

    }
}
项目:nuclei-android    文件:ExoPlayerPlayback.java   
protected MediaSource newMediaSource(Context context, String url, int type, Handler handler) {
    boolean hls = false;
    boolean localFile = url.startsWith("file://");
    if (!localFile) {
        try {
            hls = type == MediaId.TYPE_VIDEO || Uri.parse(url).getPath().endsWith(".m3u8");
        } catch (Exception ignore) {
        }
    }
    // expecting MP3 here ... otherwise HLS
    if ((localFile || type == MediaId.TYPE_AUDIO) && !hls) {
        return new ExtractorMediaSource(Uri.parse(url),
                buildDataSourceFactory(context, true, !localFile),
                new DefaultExtractorsFactory(),
                handler,
                this);
    } else {
        return new HlsMediaSource(Uri.parse(url),
                buildDataSourceFactory(context, true, true),
                handler,
                this);
    }
}
项目: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);
        }
    }
}
项目:itplayer    文件:PlayerActivity.java   
@Override
protected MediaSource[] doInBackground(MediaFile... media) {
    try {
        browser = Browser.getInstance(Config.mountDirectory);

        DataSource.Factory dataSourceFactory = new NfsDataSourceFactory(browser.getContext());
        ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
        MediaSource videoSource = new ExtractorMediaSource(Uri.parse("nfs://host/" + media[0].getPath()), dataSourceFactory, extractorsFactory, null, null);

        if (media[0].getSubtitlePath() != null) {
            Format subtitleFormat = Format.createTextSampleFormat(null, MimeTypes.APPLICATION_SUBRIP, null, Format.NO_VALUE, Format.NO_VALUE, "en", null);
            MediaSource subtitleSource = new SingleSampleMediaSource(Uri.parse("nfs://host/" + media[0].getSubtitlePath()), dataSourceFactory, subtitleFormat, Long.MAX_VALUE, 0);

            return new MediaSource[]{videoSource, subtitleSource};
        } else
            return new MediaSource[]{videoSource};
    } catch (IOException e) {
        e.printStackTrace();
    }

    return null;
}
项目: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);
    }
  }
}
项目:Komica    文件:VpxPlaybackTest.java   
@Override
public void run() {
  Looper.prepare();
  LibvpxVideoRenderer videoRenderer = new LibvpxVideoRenderer(true, 0);
  DefaultTrackSelector trackSelector = new DefaultTrackSelector();
  player = ExoPlayerFactory.newInstance(new Renderer[] {videoRenderer}, trackSelector);
  player.addListener(this);
  ExtractorMediaSource mediaSource = new ExtractorMediaSource(
      uri,
      new DefaultDataSourceFactory(context, "ExoPlayerExtVp9Test"),
      MatroskaExtractor.FACTORY,
      null,
      null);
  player.sendMessages(new ExoPlayer.ExoPlayerMessage(videoRenderer,
      LibvpxVideoRenderer.MSG_SET_OUTPUT_BUFFER_RENDERER,
      new VpxVideoSurfaceView(context)));
  player.prepare(mediaSource);
  player.setPlayWhenReady(true);
  Looper.loop();
}
项目:Komica    文件:OpusPlaybackTest.java   
@Override
public void run() {
  Looper.prepare();
  LibopusAudioRenderer audioRenderer = new LibopusAudioRenderer();
  DefaultTrackSelector trackSelector = new DefaultTrackSelector();
  player = ExoPlayerFactory.newInstance(new Renderer[] {audioRenderer}, trackSelector);
  player.addListener(this);
  ExtractorMediaSource mediaSource = new ExtractorMediaSource(
      uri,
      new DefaultDataSourceFactory(context, "ExoPlayerExtOpusTest"),
      MatroskaExtractor.FACTORY,
      null,
      null);
  player.prepare(mediaSource);
  player.setPlayWhenReady(true);
  Looper.loop();
}
项目:Komica    文件:FlacPlaybackTest.java   
@Override
public void run() {
  Looper.prepare();
  LibflacAudioRenderer audioRenderer = new LibflacAudioRenderer();
  DefaultTrackSelector trackSelector = new DefaultTrackSelector();
  player = ExoPlayerFactory.newInstance(new Renderer[] {audioRenderer}, trackSelector);
  player.addListener(this);
  ExtractorMediaSource mediaSource = new ExtractorMediaSource(
      uri,
      new DefaultDataSourceFactory(context, "ExoPlayerExtFlacTest"),
      MatroskaExtractor.FACTORY,
      null,
      null);
  player.prepare(mediaSource);
  player.setPlayWhenReady(true);
  Looper.loop();
}
项目: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    文件:VpxPlaybackTest.java   
@Override
public void run() {
  Looper.prepare();
  LibvpxVideoRenderer videoRenderer = new LibvpxVideoRenderer(true, 0);
  DefaultTrackSelector trackSelector = new DefaultTrackSelector();
  player = ExoPlayerFactory.newInstance(new Renderer[] {videoRenderer}, trackSelector);
  player.addListener(this);
  MediaSource mediaSource =
      new ExtractorMediaSource.Factory(
              new DefaultDataSourceFactory(context, "ExoPlayerExtVp9Test"))
          .setExtractorsFactory(MatroskaExtractor.FACTORY)
          .createMediaSource(uri);
  player.sendMessages(new ExoPlayer.ExoPlayerMessage(videoRenderer,
      LibvpxVideoRenderer.MSG_SET_OUTPUT_BUFFER_RENDERER,
      new VpxVideoSurfaceView(context)));
  player.prepare(mediaSource);
  player.setPlayWhenReady(true);
  Looper.loop();
}
项目:transistor    文件:OpusPlaybackTest.java   
@Override
public void run() {
  Looper.prepare();
  LibopusAudioRenderer audioRenderer = new LibopusAudioRenderer();
  DefaultTrackSelector trackSelector = new DefaultTrackSelector();
  player = ExoPlayerFactory.newInstance(new Renderer[] {audioRenderer}, trackSelector);
  player.addListener(this);
  MediaSource mediaSource =
      new ExtractorMediaSource.Factory(
              new DefaultDataSourceFactory(context, "ExoPlayerExtOpusTest"))
          .setExtractorsFactory(MatroskaExtractor.FACTORY)
          .createMediaSource(uri);
  player.prepare(mediaSource);
  player.setPlayWhenReady(true);
  Looper.loop();
}
项目:transistor    文件:FlacPlaybackTest.java   
@Override
public void run() {
  Looper.prepare();
  LibflacAudioRenderer audioRenderer = new LibflacAudioRenderer();
  DefaultTrackSelector trackSelector = new DefaultTrackSelector();
  player = ExoPlayerFactory.newInstance(new Renderer[] {audioRenderer}, trackSelector);
  player.addListener(this);
  MediaSource mediaSource =
      new ExtractorMediaSource.Factory(
              new DefaultDataSourceFactory(context, "ExoPlayerExtFlacTest"))
          .setExtractorsFactory(MatroskaExtractor.FACTORY)
          .createMediaSource(uri);
  player.prepare(mediaSource);
  player.setPlayWhenReady(true);
  Looper.loop();
}
项目:transistor    文件:AdsMediaSource.java   
/**
 * Constructs a new source that inserts ads linearly with the content specified by {@code
 * contentMediaSource}. Ad media is loaded using {@link ExtractorMediaSource}.
 *
 * @param contentMediaSource The {@link MediaSource} providing the content to play.
 * @param dataSourceFactory Factory for data sources used to load ad media.
 * @param adsLoader The loader for ads.
 * @param adUiViewGroup A {@link ViewGroup} on top of the player that will show any ad UI.
 * @param eventHandler A handler for events. May be null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 */
public AdsMediaSource(
    MediaSource contentMediaSource,
    DataSource.Factory dataSourceFactory,
    AdsLoader adsLoader,
    ViewGroup adUiViewGroup,
    @Nullable Handler eventHandler,
    @Nullable EventListener eventListener) {
  this(
      contentMediaSource,
      new ExtractorMediaSource.Factory(dataSourceFactory),
      adsLoader,
      adUiViewGroup,
      eventHandler,
      eventListener);
}
项目:yjPlay    文件:MediaSourceBuilder.java   
/****
 * 初始化视频源,无缝衔接
 *
 * @param uri 视频的地址
 * @return MediaSource media source
 */
public MediaSource initMediaSource(Uri uri) {
    int streamType = VideoPlayUtils.inferContentType(uri);
    switch (streamType) {
        case C.TYPE_OTHER:
            Log.d(TAG, "TYPE_OTHER");
            return new ExtractorMediaSource.Factory(getDataSource())
                    .setExtractorsFactory(new DefaultExtractorsFactory())
                    .setMinLoadableRetryCount(5)
                    .setCustomCacheKey(uri.getPath())
                    .createMediaSource(uri, mainHandler, null);
        default:
            throw new IllegalStateException(context.getString(R.string.media_error));
    }
}
项目: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);
    }
}
项目:lostfilm-android-client    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    if (!isPlaying) {
        Handler mainHandler = new Handler();
        BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
        TrackSelection.Factory videoTrackSelectionFactory =
                new AdaptiveVideoTrackSelection.Factory(bandwidthMeter);
        TrackSelector trackSelector =
                new DefaultTrackSelector(videoTrackSelectionFactory);

        LoadControl loadControl = new DefaultLoadControl();

        SimpleExoPlayer player =
                ExoPlayerFactory.newSimpleInstance(MainActivity.this, trackSelector, loadControl);
        SimpleExoPlayerView playerView = (SimpleExoPlayerView) findViewById(R.id.videoView);
        playerView.setPlayer(player);
        DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(MainActivity.this,
                Util.getUserAgent(MainActivity.this, "yourApplicationName"));
        MediaSource mediaSource = new ExtractorMediaSource(Uri.parse("https://r7---sn-3c27ln7k.googlevideo.com/videoplayback?id=6fb497d0971b8cdf&itag=22&source=picasa&begin=0&requiressl=yes&mm=30&mn=sn-3c27ln7k&ms=nxu&mv=m&nh=IgphcjAzLmticDAxKgkxMjcuMC4wLjE&pl=22&sc=yes&mime=video/mp4&lmt=1486083166327499&mt=1486135406&ip=134.249.158.189&ipbits=8&expire=1486164239&sparams=ip,ipbits,expire,id,itag,source,requiressl,mm,mn,ms,mv,nh,pl,sc,mime,lmt&signature=3BB06D8D4294F8C49B3CE910B3D6849954302BB1.02ABE00700DFCEF715E72D0EFB73B67841E659F8&key=ck2&ratebypass=yes&title=%5BAnime365%5D%20Kuzu%20no%20Honkai%20-%2004%20(t1174045)"), dataSourceFactory,
                new DefaultExtractorsFactory(), null, null);
        player.prepare(mediaSource);
        player.setPlayWhenReady(true);

    }
}
项目:UdacityBakingAndroid    文件:StepFragment.java   
private void initializePlayer(Uri mediaUri) {
    if (mExoPlayer == null) {
        // Create an instance of the ExoPlayer.
        TrackSelector trackSelector = new DefaultTrackSelector();
        LoadControl loadControl = new DefaultLoadControl();
        mExoPlayer = ExoPlayerFactory.newSimpleInstance(getContext(), trackSelector, loadControl);
        binding.exoStepFragmentPlayerView.setPlayer(mExoPlayer);
        mExoPlayer.addListener(this);
        String userAgent = Util.getUserAgent(getContext(), "RecipeStepVideo");
        MediaSource mediaSource = new ExtractorMediaSource(mediaUri, new DefaultDataSourceFactory(
                getContext(), userAgent), new DefaultExtractorsFactory(), null, null);
        mExoPlayer.prepare(mediaSource);
        mExoPlayer.setPlayWhenReady(true);
    }
}
项目:B4A_ExoPlayer    文件:SimpleExoPlayerWrapper.java   
/**
 * Creates a Uri source for non-streaming media resources.
 */
public Object CreateUriSource (String Uri) {
    ExtractorMediaSource e = new ExtractorMediaSource(android.net.Uri.parse(Uri), 
            createDefaultDataFactory(), 
            new DefaultExtractorsFactory(), null, null);
    return e;
}
项目:P2Video-master    文件:PlayerActivity.java   
/**
 * 播放启动视频
 */
private void startPlayer() {
    // 0.  set player view
    playerView = (SimpleExoPlayerView) findViewById(R.id.playerView);
    playerView.setUseController(false);
    playerView.getKeepScreenOn();
    playerView.setResizeMode(RESIZE_MODE_FILL);

    // 1. Create a default TrackSelector
    TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(new DefaultBandwidthMeter());
    trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);

    // 2. Create a default LoadControl
    loadControl = new DefaultLoadControl();

    // 3. Create the mPlayer
    mPlayer = ExoPlayerFactory.newSimpleInstance(this, trackSelector, loadControl);
    mPlayer.addListener(this);

    // 4. set player
    playerView.setPlayer(mPlayer);
    mPlayer.setPlayWhenReady(true);

    // 5. prepare to play
    File file = new File(Constants.FILE_VIDEO_FLODER, "jcode.mp4");
    if (file.isFile() && file.exists()) {
        mUri = Uri.fromFile(file);
    } else {
        Toast.makeText(this,"文件未找到",Toast.LENGTH_SHORT).show();
        return;
    }
    ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
    DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this, "UserAgent");
    videoSource = new ExtractorMediaSource(mUri, dataSourceFactory, extractorsFactory, null, null);

    // 6. ready to play
    mPlayer.prepare(videoSource);
}
项目:yabaking    文件:ExoPlayerManager.java   
private MediaSource setUpMediaSource(Context context, Uri mediUri) {
    final String APPLICATION_BASE_USER_AGENT = "YaBaking";
    final String userAgent = Util.getUserAgent(context, APPLICATION_BASE_USER_AGENT);
    return new ExtractorMediaSource(
            mediUri,
            new DefaultDataSourceFactory(context, userAgent),
            new DefaultExtractorsFactory(),
            null, null);
}
项目:R-a-dio-Amazing-Android-App    文件:RadioService.java   
public void setupMediaPlayer() {
    DataSource.Factory dsf = new DefaultDataSourceFactory(this,
            Util.getUserAgent(this, "R/a/dio-Android-App"));
    ExtractorsFactory extractors = new DefaultExtractorsFactory();
    MediaSource audioSource = new ExtractorMediaSource(Uri.parse(radio_url), dsf, extractors, null, null);

    if(sep != null)
        sep.prepare(audioSource);
}
项目:AndroidAudioExample    文件:PlayerService.java   
private void prepareToPlay(Uri uri) {
    if (!uri.equals(currentUri)) {
        currentUri = uri;
        ExtractorMediaSource mediaSource = new ExtractorMediaSource(uri, dataSourceFactory, extractorsFactory, null, null);
        exoPlayer.prepare(mediaSource);
    }
}