Search in sources :

Example 16 with Timeline

use of com.google.android.exoplayer2.Timeline in project ExoPlayer by google.

the class ClippingMediaSourceTest method testClippingStart.

public void testClippingStart() {
    Timeline timeline = new SinglePeriodTimeline(C.msToUs(TEST_PERIOD_DURATION_US), true);
    Timeline clippedTimeline = getClippedTimeline(timeline, TEST_CLIP_AMOUNT_US, TEST_PERIOD_DURATION_US);
    assertEquals(TEST_PERIOD_DURATION_US - TEST_CLIP_AMOUNT_US, clippedTimeline.getWindow(0, window).getDurationUs());
    assertEquals(TEST_PERIOD_DURATION_US - TEST_CLIP_AMOUNT_US, clippedTimeline.getPeriod(0, period).getDurationUs());
}
Also used : Timeline(com.google.android.exoplayer2.Timeline)

Example 17 with Timeline

use of com.google.android.exoplayer2.Timeline in project ExoPlayer by google.

the class ClippingMediaSourceTest method getClippedTimeline.

/**
   * Wraps the specified timeline in a {@link ClippingMediaSource} and returns the clipped timeline.
   */
private Timeline getClippedTimeline(Timeline timeline, long startMs, long endMs) {
    mockMediaSourceSourceWithTimeline(timeline);
    new ClippingMediaSource(mockMediaSource, startMs, endMs).prepareSource(null, true, new Listener() {

        @Override
        public void onSourceInfoRefreshed(Timeline timeline, Object manifest) {
            clippedTimeline = timeline;
        }
    });
    return clippedTimeline;
}
Also used : Timeline(com.google.android.exoplayer2.Timeline) Listener(com.google.android.exoplayer2.source.MediaSource.Listener)

Example 18 with Timeline

use of com.google.android.exoplayer2.Timeline in project ExoPlayer by google.

the class ConcatenatingMediaSource method handleSourceInfoRefreshed.

private void handleSourceInfoRefreshed(int sourceFirstIndex, Timeline sourceTimeline, Object sourceManifest) {
    // Set the timeline and manifest.
    timelines[sourceFirstIndex] = sourceTimeline;
    manifests[sourceFirstIndex] = sourceManifest;
    // Also set the timeline and manifest for any duplicate entries of the same source.
    for (int i = sourceFirstIndex + 1; i < mediaSources.length; i++) {
        if (mediaSources[i] == mediaSources[sourceFirstIndex]) {
            timelines[i] = sourceTimeline;
            manifests[i] = sourceManifest;
        }
    }
    for (Timeline timeline : timelines) {
        if (timeline == null) {
            // Don't invoke the listener until all sources have timelines.
            return;
        }
    }
    timeline = new ConcatenatedTimeline(timelines.clone());
    listener.onSourceInfoRefreshed(timeline, manifests.clone());
}
Also used : Timeline(com.google.android.exoplayer2.Timeline)

Example 19 with Timeline

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

the class ReactExoplayerView method releasePlayer.

private void releasePlayer() {
    if (player != null) {
        isPaused = player.getPlayWhenReady();
        shouldRestorePosition = false;
        playerWindow = player.getCurrentWindowIndex();
        playerPosition = C.TIME_UNSET;
        Timeline timeline = player.getCurrentTimeline();
        if (!timeline.isEmpty() && timeline.getWindow(playerWindow, window).isSeekable) {
            playerPosition = player.getCurrentPosition();
        }
        player.release();
        player.setMetadataOutput(null);
        player = null;
        trackSelector = null;
    }
    progressHandler.removeMessages(SHOW_PROGRESS);
    themedReactContext.removeLifecycleEventListener(this);
    audioBecomingNoisyReceiver.removeListener();
}
Also used : Timeline(com.google.android.exoplayer2.Timeline)

Example 20 with Timeline

use of com.google.android.exoplayer2.Timeline in project LeafPic by HoraApps.

the class CustomPlayBackController method previous.

private void previous() {
    Timeline currentTimeline = player.getCurrentTimeline();
    if (currentTimeline == null) {
        return;
    }
    int currentWindowIndex = player.getCurrentWindowIndex();
    currentTimeline.getWindow(currentWindowIndex, window);
    if (currentWindowIndex > 0 && (player.getCurrentPosition() <= MAX_POSITION_FOR_SEEK_TO_PREVIOUS || (window.isDynamic && !window.isSeekable))) {
        player.seekToDefaultPosition(currentWindowIndex - 1);
    } else {
        player.seekTo(0);
    }
}
Also used : Timeline(com.google.android.exoplayer2.Timeline)

Aggregations

Timeline (com.google.android.exoplayer2.Timeline)15 MediaSource (com.google.android.exoplayer2.source.MediaSource)4 SinglePeriodTimeline (com.google.android.exoplayer2.source.SinglePeriodTimeline)2 Listener (com.google.android.exoplayer2.source.MediaSource.Listener)1 SampleStream (com.google.android.exoplayer2.source.SampleStream)1 TrackGroup (com.google.android.exoplayer2.source.TrackGroup)1 TrackGroupArray (com.google.android.exoplayer2.source.TrackGroupArray)1 StreamElement (com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest.StreamElement)1 TrackSelection (com.google.android.exoplayer2.trackselection.TrackSelection)1 TrackSelectorResult (com.google.android.exoplayer2.trackselection.TrackSelectorResult)1