Search in sources :

Example 1 with TrackSelectionArray

use of com.google.android.exoplayer2.trackselection.TrackSelectionArray in project ExoPlayer by google.

the class PlayerActivity method onTracksChanged.

@Override
public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
    updateButtonVisibilities();
    MappedTrackInfo mappedTrackInfo = trackSelector.getCurrentMappedTrackInfo();
    if (mappedTrackInfo != null) {
        if (mappedTrackInfo.getTrackTypeRendererSupport(C.TRACK_TYPE_VIDEO) == MappedTrackInfo.RENDERER_SUPPORT_UNSUPPORTED_TRACKS) {
            showToast(R.string.error_unsupported_video);
        }
        if (mappedTrackInfo.getTrackTypeRendererSupport(C.TRACK_TYPE_AUDIO) == MappedTrackInfo.RENDERER_SUPPORT_UNSUPPORTED_TRACKS) {
            showToast(R.string.error_unsupported_audio);
        }
    }
}
Also used : MappedTrackInfo(com.google.android.exoplayer2.trackselection.MappingTrackSelector.MappedTrackInfo)

Example 2 with TrackSelectionArray

use of com.google.android.exoplayer2.trackselection.TrackSelectionArray in project ExoPlayer by google.

the class SimpleExoPlayerView method updateForCurrentTrackSelections.

private void updateForCurrentTrackSelections() {
    if (player == null) {
        return;
    }
    TrackSelectionArray selections = player.getCurrentTrackSelections();
    for (int i = 0; i < selections.length; i++) {
        if (player.getRendererType(i) == C.TRACK_TYPE_VIDEO && selections.get(i) != null) {
            // Video enabled so artwork must be hidden. If the shutter is closed, it will be opened in
            // onRenderedFirstFrame().
            hideArtwork();
            return;
        }
    }
    // Video disabled so the shutter must be closed.
    if (shutterView != null) {
        shutterView.setVisibility(VISIBLE);
    }
    // Display artwork if enabled and available, else hide it.
    if (useArtwork) {
        for (int i = 0; i < selections.length; i++) {
            TrackSelection selection = selections.get(i);
            if (selection != null) {
                for (int j = 0; j < selection.length(); j++) {
                    Metadata metadata = selection.getFormat(j).metadata;
                    if (metadata != null && setArtworkFromMetadata(metadata)) {
                        return;
                    }
                }
            }
        }
        if (setArtworkFromBitmap(defaultArtwork)) {
            return;
        }
    }
    // Artwork disabled or unavailable.
    hideArtwork();
}
Also used : Metadata(com.google.android.exoplayer2.metadata.Metadata) TrackSelection(com.google.android.exoplayer2.trackselection.TrackSelection) TrackSelectionArray(com.google.android.exoplayer2.trackselection.TrackSelectionArray)

Example 3 with TrackSelectionArray

use of com.google.android.exoplayer2.trackselection.TrackSelectionArray in project react-native-video by react-native-community.

the class ExoPlayerView method updateForCurrentTrackSelections.

private void updateForCurrentTrackSelections() {
    if (player == null) {
        return;
    }
    TrackSelectionArray selections = player.getCurrentTrackSelections();
    for (int i = 0; i < selections.length; i++) {
        if (player.getRendererType(i) == C.TRACK_TYPE_VIDEO && selections.get(i) != null) {
            // onRenderedFirstFrame().
            return;
        }
    }
    // Video disabled so the shutter must be closed.
    shutterView.setVisibility(VISIBLE);
}
Also used : TrackSelectionArray(com.google.android.exoplayer2.trackselection.TrackSelectionArray)

Example 4 with TrackSelectionArray

use of com.google.android.exoplayer2.trackselection.TrackSelectionArray in project RandomWebm by alkocher.

the class RandomFragment method initPlayer.

private void initPlayer(String VIDEO_URL) {
    playerView.setPlayer(player);
    MediaSource mediaSource = new ExtractorMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse(VIDEO_URL));
    player.prepare(mediaSource);
    player.setPlayWhenReady(true);
    // Progress bar
    player.addListener(new ExoPlayer.EventListener() {

        @Override
        public void onTimelineChanged(Timeline timeline, Object manifest) {
        }

        @Override
        public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
        }

        @Override
        public void onLoadingChanged(boolean isLoading) {
        }

        @Override
        public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
            if (playbackState == ExoPlayer.STATE_BUFFERING) {
                progressBar.setVisibility(View.VISIBLE);
            } else {
                progressBar.setVisibility(View.GONE);
            }
        }

        @Override
        public void onRepeatModeChanged(int repeatMode) {
        }

        @Override
        public void onShuffleModeEnabledChanged(boolean shuffleModeEnabled) {
        }

        @Override
        public void onPlayerError(ExoPlaybackException error) {
        }

        @Override
        public void onPositionDiscontinuity(int reason) {
        }

        @Override
        public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) {
        }

        @Override
        public void onSeekProcessed() {
        }
    });
}
Also used : TrackGroupArray(com.google.android.exoplayer2.source.TrackGroupArray) ExoPlaybackException(com.google.android.exoplayer2.ExoPlaybackException) ExtractorMediaSource(com.google.android.exoplayer2.source.ExtractorMediaSource) SimpleExoPlayer(com.google.android.exoplayer2.SimpleExoPlayer) ExoPlayer(com.google.android.exoplayer2.ExoPlayer) TrackSelectionArray(com.google.android.exoplayer2.trackselection.TrackSelectionArray) Timeline(com.google.android.exoplayer2.Timeline) MediaSource(com.google.android.exoplayer2.source.MediaSource) ExtractorMediaSource(com.google.android.exoplayer2.source.ExtractorMediaSource) PlaybackParameters(com.google.android.exoplayer2.PlaybackParameters)

Example 5 with TrackSelectionArray

use of com.google.android.exoplayer2.trackselection.TrackSelectionArray in project RandomWebm by alkocher.

the class PlayerActivity method initPlayer.

private void initPlayer(String VIDEO_URL) {
    playerView.setPlayer(player);
    MediaSource mediaSource = new ExtractorMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse(VIDEO_URL));
    player.prepare(mediaSource);
    player.setPlayWhenReady(true);
    // Loading Bar
    player.addListener(new ExoPlayer.EventListener() {

        @Override
        public void onTimelineChanged(Timeline timeline, Object manifest) {
        }

        @Override
        public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
        }

        @Override
        public void onLoadingChanged(boolean isLoading) {
        }

        @Override
        public void onRepeatModeChanged(int repeatMode) {
        }

        @Override
        public void onShuffleModeEnabledChanged(boolean shuffleModeEnabled) {
        }

        @Override
        public void onPlayerError(ExoPlaybackException error) {
        }

        @Override
        public void onPositionDiscontinuity(int reason) {
        }

        @Override
        public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) {
        }

        @Override
        public void onSeekProcessed() {
        }

        @Override
        public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
            if (playbackState == ExoPlayer.STATE_BUFFERING) {
                progressBar.setVisibility(View.VISIBLE);
            } else {
                progressBar.setVisibility(View.INVISIBLE);
            }
        }
    });
}
Also used : TrackGroupArray(com.google.android.exoplayer2.source.TrackGroupArray) ExoPlaybackException(com.google.android.exoplayer2.ExoPlaybackException) ExtractorMediaSource(com.google.android.exoplayer2.source.ExtractorMediaSource) SimpleExoPlayer(com.google.android.exoplayer2.SimpleExoPlayer) ExoPlayer(com.google.android.exoplayer2.ExoPlayer) TrackSelectionArray(com.google.android.exoplayer2.trackselection.TrackSelectionArray) Timeline(com.google.android.exoplayer2.Timeline) ExtractorMediaSource(com.google.android.exoplayer2.source.ExtractorMediaSource) MediaSource(com.google.android.exoplayer2.source.MediaSource) PlaybackParameters(com.google.android.exoplayer2.PlaybackParameters)

Aggregations

TrackSelectionArray (com.google.android.exoplayer2.trackselection.TrackSelectionArray)10 TrackGroupArray (com.google.android.exoplayer2.source.TrackGroupArray)8 TrackGroup (com.google.android.exoplayer2.source.TrackGroup)5 TrackSelection (com.google.android.exoplayer2.trackselection.TrackSelection)5 AnalyticsListener (com.google.android.exoplayer2.analytics.AnalyticsListener)3 Metadata (com.google.android.exoplayer2.metadata.Metadata)3 MediaSource (com.google.android.exoplayer2.source.MediaSource)3 MappedTrackInfo (com.google.android.exoplayer2.trackselection.MappingTrackSelector.MappedTrackInfo)3 ExoPlaybackException (com.google.android.exoplayer2.ExoPlaybackException)2 ExoPlayer (com.google.android.exoplayer2.ExoPlayer)2 PlaybackParameters (com.google.android.exoplayer2.PlaybackParameters)2 SimpleExoPlayer (com.google.android.exoplayer2.SimpleExoPlayer)2 Timeline (com.google.android.exoplayer2.Timeline)2 ExtractorMediaSource (com.google.android.exoplayer2.source.ExtractorMediaSource)2 SinglePeriodTimeline (com.google.android.exoplayer2.source.SinglePeriodTimeline)2 ActionSchedule (com.google.android.exoplayer2.testutil.ActionSchedule)2 ExoPlayerTestRunner (com.google.android.exoplayer2.testutil.ExoPlayerTestRunner)2 FakeMediaSource (com.google.android.exoplayer2.testutil.FakeMediaSource)2 FakeTimeline (com.google.android.exoplayer2.testutil.FakeTimeline)2 NoUidTimeline (com.google.android.exoplayer2.testutil.NoUidTimeline)2