Java 类com.google.android.exoplayer2.extractor.DefaultExtractorsFactory 实例源码

项目: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);
        }
    }
}
项目:syncplayer    文件:MediaService.java   
@Override
public IBinder onBind(final Intent intent) {

    bandwidthMeter = new DefaultBandwidthMeter();
    TrackSelection.Factory videoTrackSelectionFactory =
            new AdaptiveTrackSelection.Factory(bandwidthMeter);

    dataSourceFactory = new DefaultDataSourceFactory(this,
            Util.getUserAgent(this, "SyncPlayer"), bandwidthMeter);

    extractorsFactory = new DefaultExtractorsFactory();

    TrackSelector trackSelector =
            new DefaultTrackSelector(videoTrackSelectionFactory);

    LoadControl loadControl = new DefaultLoadControl();

    SimpleExoPlayer player =
            ExoPlayerFactory.newSimpleInstance(getApplicationContext(), trackSelector, loadControl);
    mMediaPlayer = player;

    setCompletionListener();
    nbuilder.setSmallIcon(R.mipmap.ic_launcher);
    return mBinder;
}
项目: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);
    }
  }
}
项目:Jockey    文件:QueuedExoPlayer.java   
private void prepare(boolean playWhenReady, boolean resetPosition) {
    mInvalid = false;

    if (mQueue == null) {
        return;
    }

    DataSource.Factory srcFactory = new DefaultDataSourceFactory(mContext, USER_AGENT);
    ExtractorsFactory extFactory = new DefaultExtractorsFactory();

    int startingPosition = resetPosition ? 0 : getCurrentPosition();

    if (mRepeatOne) {
        mExoPlayer.prepare(buildRepeatOneMediaSource(srcFactory, extFactory));
    } else if (mRepeatAll) {
        mExoPlayer.prepare(buildRepeatAllMediaSource(srcFactory, extFactory));
    } else {
        mExoPlayer.prepare(buildNoRepeatMediaSource(srcFactory, extFactory));
    }

    mExoPlayer.seekTo(mQueueIndex, startingPosition);
    mExoPlayer.setPlayWhenReady(playWhenReady);
}
项目: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   
@Override
public void onCreate() {
    super.onCreate();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        NotificationChannel notificationChannel = new NotificationChannel(NOTIFICATION_DEFAULT_CHANNEL_ID, getString(R.string.notification_channel_name), NotificationManagerCompat.IMPORTANCE_DEFAULT);
        NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.createNotificationChannel(notificationChannel);

        AudioAttributes audioAttributes = new AudioAttributes.Builder()
                .setUsage(AudioAttributes.USAGE_MEDIA)
                .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
                .build();
        audioFocusRequest = new AudioFocusRequest.Builder(AudioManager.AUDIOFOCUS_GAIN)
                .setOnAudioFocusChangeListener(audioFocusChangeListener)
                .setAcceptsDelayedFocusGain(false)
                .setWillPauseWhenDucked(true)
                .setAudioAttributes(audioAttributes)
                .build();
    }

    audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);

    mediaSession = new MediaSessionCompat(this, "PlayerService");
    mediaSession.setFlags(MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS | MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS);
    mediaSession.setCallback(mediaSessionCallback);

    Context appContext = getApplicationContext();

    Intent activityIntent = new Intent(appContext, MainActivity.class);
    mediaSession.setSessionActivity(PendingIntent.getActivity(appContext, 0, activityIntent, 0));

    Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null, appContext, MediaButtonReceiver.class);
    mediaSession.setMediaButtonReceiver(PendingIntent.getBroadcast(appContext, 0, mediaButtonIntent, 0));

    exoPlayer = ExoPlayerFactory.newSimpleInstance(new DefaultRenderersFactory(this), new DefaultTrackSelector(), new DefaultLoadControl());
    exoPlayer.addListener(exoPlayerListener);
    DataSource.Factory httpDataSourceFactory = new OkHttpDataSourceFactory(new OkHttpClient(), Util.getUserAgent(this, getString(R.string.app_name)), null);
    Cache cache = new SimpleCache(new File(this.getCacheDir().getAbsolutePath() + "/exoplayer"), new LeastRecentlyUsedCacheEvictor(1024 * 1024 * 100)); // 100 Mb max
    this.dataSourceFactory = new CacheDataSourceFactory(cache, httpDataSourceFactory, CacheDataSource.FLAG_BLOCK_ON_CACHE | CacheDataSource.FLAG_IGNORE_CACHE_ON_ERROR);
    this.extractorsFactory = new DefaultExtractorsFactory();
}
项目:react-native-exoplayer-intent-video    文件:PlayerController.java   
public PlayerController(Context context) {
    this.bandwidthMeter = new DefaultBandwidthMeter();
    this.loadControl = new DefaultLoadControl();
    this.extractorsFactory = new DefaultExtractorsFactory();
    this.trackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter);
    this.dataSourceFactory = new DefaultDataSourceFactory(context, Util.getUserAgent(context.getApplicationContext(), TAG_NAME), (TransferListener<? super DataSource>) bandwidthMeter);
    this.trackSelector = new DefaultTrackSelector(trackSelectionFactory);
    this.player = ExoPlayerFactory.newSimpleInstance(context, this.trackSelector, this.loadControl);
    this.playerView = new PlayerView(context,this.player);
}
项目:tumbviewer    文件:ExoPlayerInstance.java   
private ExoPlayerInstance() {
    this.context = ExpressApplication.getApplication();
    DefaultBandwidthMeter defaultBandwidthMeter = new DefaultBandwidthMeter();
    mainHandler = new Handler();
    defaultExtractorsFactory = new DefaultExtractorsFactory();
    mediaDataSourceFactory = new DefaultDataSourceFactory(context, defaultBandwidthMeter,
            new OkHttpDataSourceFactory(new OkHttpClient.Builder().build(),
                    Util.getUserAgent(context, "Tumbviewer"),
                    defaultBandwidthMeter, CacheControl.FORCE_NETWORK));
    TrackSelection.Factory factory = new AdaptiveTrackSelection.Factory(defaultBandwidthMeter);
    trackSelector = new DefaultTrackSelector(factory);
}
项目:MyAnimeViewer    文件:VideoDetailsFragment.java   
private MediaSource getMediaSource(String videoUrl) {
        DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
        // Produces DataSource instances through which media data is loaded.
//        DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(getContext(), Util.getUserAgent(getContext(), "Loop"), bandwidthMeter);
        DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(MAVApplication.getInstance().getApplicationContext(), Util.getUserAgent(MAVApplication.getInstance().getApplicationContext(), "Loop"), bandwidthMeter);
        // Produces Extractor instances for parsing the media data.
        ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
        // This is the MediaSource representing the media to be played.
        MediaSource mediaSource = new ExtractorMediaSource(Uri.parse(videoUrl),
                dataSourceFactory, extractorsFactory, null, null);
        // Loops the video indefinitely.
//        LoopingMediaSource loopingSource = new LoopingMediaSource(mediaSource);
        return mediaSource;
    }
项目:MyAnimeViewer    文件:OfflineVideoDetailsFragment.java   
private MediaSource getMediaSource(String videoUrl) {
        DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
        // Produces DataSource instances through which media data is loaded.
//        DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(getContext(), Util.getUserAgent(getContext(), "Loop"), bandwidthMeter);
        DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(MAVApplication.getInstance().getApplicationContext(), Util.getUserAgent(MAVApplication.getInstance().getApplicationContext(), "Loop"), bandwidthMeter);
        // Produces Extractor instances for parsing the media data.
        ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
        // This is the MediaSource representing the media to be played.
        MediaSource mediaSource = new ExtractorMediaSource(Uri.parse(videoUrl),
                dataSourceFactory, extractorsFactory, null, null);
        // Loops the video indefinitely.
//        LoopingMediaSource loopingSource = new LoopingMediaSource(mediaSource);
        return mediaSource;
    }
项目:MyAnimeViewer    文件:VideoPlayerActivity.java   
private MediaSource getMediaSource(String videoUrl) {
        DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
        // Produces DataSource instances through which media data is loaded.
//        DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this, Util.getUserAgent(this, "Loop"), bandwidthMeter);
        DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(MAVApplication.getInstance().getApplicationContext(), Util.getUserAgent(MAVApplication.getInstance().getApplicationContext(), "Loop"), bandwidthMeter);
        // Produces Extractor instances for parsing the media data.
        ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
        // This is the MediaSource representing the media to be played.
        MediaSource mediaSource = new ExtractorMediaSource(Uri.parse(videoUrl),
                dataSourceFactory, extractorsFactory, null, null);
        // Loops the video indefinitely.
//        LoopingMediaSource loopingSource = new LoopingMediaSource(mediaSource);
        return mediaSource;
    }
项目:mobile-app-dev-book    文件:MediaViewActivity.java   
private void initExoPlayer() {
    DefaultBandwidthMeter bwMeter = new DefaultBandwidthMeter();
    AdaptiveTrackSelection.Factory trackFactory = new AdaptiveTrackSelection.Factory(bwMeter);
    DefaultTrackSelector trackSelector = new DefaultTrackSelector(trackFactory);
    player = ExoPlayerFactory.newSimpleInstance(this, trackSelector);
    videoView.setPlayer(player);

    DataSource.Factory dsFactory = new DefaultDataSourceFactory(getBaseContext(),
            Util.getUserAgent(this, "Traxy"), bwMeter);
    ExtractorsFactory exFactory = new DefaultExtractorsFactory();
    Uri mediaUri = Uri.parse(entry.getUrl());
    MediaSource videoSource = new ExtractorMediaSource(mediaUri,
            dsFactory, exFactory, null, null);
    player.prepare(videoSource);
}
项目:mobile-app-dev-book    文件:MediaViewActivity.java   
private void initExoPlayer() {
    DefaultBandwidthMeter bwMeter = new DefaultBandwidthMeter();
    AdaptiveTrackSelection.Factory trackFactory = new AdaptiveTrackSelection.Factory(bwMeter);
    DefaultTrackSelector trackSelector = new DefaultTrackSelector(trackFactory);
    player = ExoPlayerFactory.newSimpleInstance(this, trackSelector);
    videoView.setPlayer(player);

    DataSource.Factory dsFactory = new DefaultDataSourceFactory(getBaseContext(),
            Util.getUserAgent(this, "Traxy"), bwMeter);
    ExtractorsFactory exFactory = new DefaultExtractorsFactory();
    Uri mediaUri = Uri.parse(entry.getUrl());
    MediaSource videoSource = new ExtractorMediaSource(mediaUri,
            dsFactory, exFactory, null, null);
    player.prepare(videoSource);
}
项目:mobile-app-dev-book    文件:MediaViewActivity.java   
private void initExoPlayer() {
    DefaultBandwidthMeter bwMeter = new DefaultBandwidthMeter();
    AdaptiveTrackSelection.Factory trackFactory = new AdaptiveTrackSelection.Factory(bwMeter);
    DefaultTrackSelector trackSelector = new DefaultTrackSelector(trackFactory);
    player = ExoPlayerFactory.newSimpleInstance(this, trackSelector);
    videoView.setPlayer(player);

    DataSource.Factory dsFactory = new DefaultDataSourceFactory(getBaseContext(),
            Util.getUserAgent(this, "Traxy"), bwMeter);
    ExtractorsFactory exFactory = new DefaultExtractorsFactory();
    Uri mediaUri = Uri.parse(entry.getUrl());
    MediaSource videoSource = new ExtractorMediaSource(mediaUri,
            dsFactory, exFactory, null, null);
    player.prepare(videoSource);
}