com.google.android.exoplayer2.trackselection.AdaptiveVideoTrackSelection Java Examples

The following examples show how to use com.google.android.exoplayer2.trackselection.AdaptiveVideoTrackSelection. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExoMedia.java    From QSVideoPlayer with Apache License 2.0 5 votes vote down vote up
@Override
public boolean doPrepar(Context context, String url, Map<String, String> headers, Object... objects) {
    release();
    TrackSelection.Factory videoTrackSelectionFactory =
            new AdaptiveVideoTrackSelection.Factory(BANDWIDTH_METER);
    DefaultTrackSelector trackSelector = new DefaultTrackSelector(mainThreadHandler, videoTrackSelectionFactory);
    simpleExoPlayer = ExoPlayerFactory.newSimpleInstance(context, trackSelector, new DefaultLoadControl(),
            null, false);
    simpleExoPlayer.setPlayWhenReady(true);
    MediaSource mediaSource = buildMediaSource(context, Uri.parse(url));
    simpleExoPlayer.addListener(ExoMedia.this);
    simpleExoPlayer.setVideoListener(ExoMedia.this);
    simpleExoPlayer.prepare(mediaSource, true, true);
    return true;
}
 
Example #2
Source File: VideoDetailsFragment.java    From Loop with Apache License 2.0 5 votes vote down vote up
private TrackSelector createTrackSelector(){
    // Create a default TrackSelector
    // Measures bandwidth during playback. Can be null if not required.
    BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
    TrackSelection.Factory videoTrackSelectionFactory =
            new AdaptiveVideoTrackSelection.Factory(bandwidthMeter);
    TrackSelector trackSelector =
            new DefaultTrackSelector(videoTrackSelectionFactory);
    return trackSelector;
}
 
Example #3
Source File: ExoHostedTest.java    From ExoPlayer-Offline with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unused")
protected MappingTrackSelector buildTrackSelector(HostActivity host,
    BandwidthMeter bandwidthMeter) {
  return new DefaultTrackSelector(new AdaptiveVideoTrackSelection.Factory(bandwidthMeter));
}
 
Example #4
Source File: VideoActivity.java    From evercam-android with GNU Affero General Public License v3.0 4 votes vote down vote up
private void preparePlayer() {

        if (player == null){

            DrmSessionManager<FrameworkMediaCrypto> drmSessionManager = null;

            @SimpleExoPlayer.ExtensionRendererMode int extensionRendererMode =
                    ((EvercamPlayApplication) getApplication()).useExtensionRenderers()
                            ? (false ? SimpleExoPlayer.EXTENSION_RENDERER_MODE_PREFER
                            : SimpleExoPlayer.EXTENSION_RENDERER_MODE_ON)
                            : SimpleExoPlayer.EXTENSION_RENDERER_MODE_OFF;

            TrackSelection.Factory videoTrackSelectionFactory =
                    new AdaptiveVideoTrackSelection.Factory(BANDWIDTH_METER);

            trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);

            player = ExoPlayerFactory.newSimpleInstance(this, trackSelector, new DefaultLoadControl(),
                    drmSessionManager, extensionRendererMode);
            player.addListener(this);

            eventLogger = new EventLogger(trackSelector);
            eventLogger.addListener(this);
            player.addListener(eventLogger);
//        player.setAudioDebugListener(eventLogger);
            player.setVideoDebugListener(eventLogger);
            player.setMetadataOutput(eventLogger);

            Uri hlsUrl = Uri.parse(evercamCamera.getHlsUrl());

            MediaSource mediaSource = new HlsMediaSource(hlsUrl, mediaDataSourceFactory, mainHandler, eventLogger);


            boolean haveResumePosition = resumeWindow != C.INDEX_UNSET;
            if (haveResumePosition) {
                player.seekTo(resumeWindow, resumePosition);
            }
            player.prepare(mediaSource, !haveResumePosition, false);

            player.setPlayWhenReady(true);
            player.setVideoSurface(surface);

        }else{
            releasePlayer();
            preparePlayer();
        }


        /*DrmSessionManager<FrameworkMediaCrypto> drmSessionManager = null;

        @SimpleExoPlayer.ExtensionRendererMode int extensionRendererMode =
                ((EvercamPlayApplication) getApplication()).useExtensionRenderers()
                        ? (false ? SimpleExoPlayer.EXTENSION_RENDERER_MODE_PREFER
                        : SimpleExoPlayer.EXTENSION_RENDERER_MODE_ON)
                        : SimpleExoPlayer.EXTENSION_RENDERER_MODE_OFF;

        TrackSelection.Factory videoTrackSelectionFactory =
                new AdaptiveVideoTrackSelection.Factory(BANDWIDTH_METER);

        trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);

        player = ExoPlayerFactory.newSimpleInstance(this, trackSelector, new DefaultLoadControl(),
                drmSessionManager, extensionRendererMode);
        player.addListener(this);
        eventLogger = new EventLogger(trackSelector);
        eventLogger.addListener(this);
        player.addListener(eventLogger);
//        player.setAudioDebugListener(eventLogger);
        player.setVideoDebugListener(eventLogger);
        player.setMetadataOutput(eventLogger);
        Uri hlsUrl = Uri.parse(evercamCamera.getHlsUrl());
        MediaSource mediaSource = new HlsMediaSource(hlsUrl, mediaDataSourceFactory, mainHandler, eventLogger);

        player.prepare(mediaSource);
        player.setPlayWhenReady(true);
        player.setVideoSurface(surface);*/
    }