當前位置: 首頁>>代碼示例>>Java>>正文


Java Timeline類代碼示例

本文整理匯總了Java中com.google.android.exoplayer2.Timeline的典型用法代碼示例。如果您正苦於以下問題:Java Timeline類的具體用法?Java Timeline怎麽用?Java Timeline使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Timeline類屬於com.google.android.exoplayer2包,在下文中一共展示了Timeline類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createViews

import com.google.android.exoplayer2.Timeline; //導入依賴的package包/類
private void createViews() {
    mediaDataSourceFactory = buildDataSourceFactory(true);
    mainHandler = new Handler();
    window = new Timeline.Window();
    if (CookieHandler.getDefault() != DEFAULT_COOKIE_MANAGER) {
        CookieHandler.setDefault(DEFAULT_COOKIE_MANAGER);
    }

    LayoutParams layoutParams = new LayoutParams(
            LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT);
    exoPlayerView = new ExoPlayerView(getContext());
    exoPlayerView.setLayoutParams(layoutParams);

    addView(exoPlayerView, 0, layoutParams);
}
 
開發者ID:12d,項目名稱:react-native-videoplayer,代碼行數:17,代碼來源:ReactExoplayerView.java

示例2: releasePlayer

import com.google.android.exoplayer2.Timeline; //導入依賴的package包/類
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 = null;
        trackSelector = null;
    }
    progressHandler.removeMessages(SHOW_PROGRESS);
    themedReactContext.removeLifecycleEventListener(this);
    audioBecomingNoisyReceiver.removeListener();
}
 
開發者ID:12d,項目名稱:react-native-videoplayer,代碼行數:19,代碼來源:ReactExoplayerView.java

示例3: ImaAdsLoader

import com.google.android.exoplayer2.Timeline; //導入依賴的package包/類
/**
 * Creates a new IMA ads loader.
 *
 * @param context The context.
 * @param adTagUri The {@link Uri} of an ad tag compatible with the Android IMA SDK. See
 *     https://developers.google.com/interactive-media-ads/docs/sdks/android/compatibility for
 *     more information.
 * @param imaSdkSettings {@link ImaSdkSettings} used to configure the IMA SDK, or {@code null} to
 *     use the default settings. If set, the player type and version fields may be overwritten.
 */
public ImaAdsLoader(Context context, Uri adTagUri, ImaSdkSettings imaSdkSettings) {
  this.adTagUri = adTagUri;
  period = new Timeline.Period();
  adCallbacks = new ArrayList<>(1);
  imaSdkFactory = ImaSdkFactory.getInstance();
  adDisplayContainer = imaSdkFactory.createAdDisplayContainer();
  adDisplayContainer.setPlayer(this);
  if (imaSdkSettings == null) {
    imaSdkSettings = imaSdkFactory.createImaSdkSettings();
  }
  imaSdkSettings.setPlayerType(IMA_SDK_SETTINGS_PLAYER_TYPE);
  imaSdkSettings.setPlayerVersion(IMA_SDK_SETTINGS_PLAYER_VERSION);
  adsLoader = imaSdkFactory.createAdsLoader(context, imaSdkSettings);
  adsLoader.addAdErrorListener(this);
  adsLoader.addAdsLoadedListener(this);
  fakeContentProgressElapsedRealtimeMs = C.TIME_UNSET;
  fakeContentProgressOffsetMs = C.TIME_UNSET;
  pendingContentPositionMs = C.TIME_UNSET;
  adGroupIndex = C.INDEX_UNSET;
  contentDurationMs = C.TIME_UNSET;
}
 
開發者ID:yangchaojiang,項目名稱:yjPlay,代碼行數:32,代碼來源:ImaAdsLoader.java

示例4: updateNavigation

import com.google.android.exoplayer2.Timeline; //導入依賴的package包/類
private void updateNavigation() {
    if (!isVisible() || !isAttachedToWindow) {
        return;
    }
    Timeline timeline = player != null ? player.getCurrentTimeline() : null;
    boolean haveNonEmptyTimeline = timeline != null && !timeline.isEmpty();
    boolean isSeekable = false;
    boolean enablePrevious = false;
    boolean enableNext = false;
    if (haveNonEmptyTimeline && !player.isPlayingAd()) {
        int windowIndex = player.getCurrentWindowIndex();
        timeline.getWindow(windowIndex, window);
        isSeekable = window.isSeekable;
        enablePrevious = isSeekable || !window.isDynamic
                || player.getPreviousWindowIndex() != C.INDEX_UNSET;
        enableNext = window.isDynamic || player.getNextWindowIndex() != C.INDEX_UNSET;
    }
    setButtonEnabled(enablePrevious, previousButton);
    setButtonEnabled(enableNext, nextButton);
    setButtonEnabled(fastForwardMs > 0 && isSeekable, fastForwardButton);
    setButtonEnabled(rewindMs > 0 && isSeekable, rewindButton);
    if (timeBar != null) {
        timeBar.setEnabled(isSeekable);
    }
}
 
開發者ID:yangchaojiang,項目名稱:yjPlay,代碼行數:26,代碼來源:PlaybackControlView.java

示例5: previous

import com.google.android.exoplayer2.Timeline; //導入依賴的package包/類
public void previous() {
    Timeline timeline = player.getCurrentTimeline();
    if (timeline.isEmpty()) {
        return;
    }
    int windowIndex = player.getCurrentWindowIndex();
    timeline.getWindow(windowIndex, window);
    int previousWindowIndex = player.getPreviousWindowIndex();
    if (previousWindowIndex != C.INDEX_UNSET
            && (player.getCurrentPosition() <= MAX_POSITION_FOR_SEEK_TO_PREVIOUS
            || (window.isDynamic && !window.isSeekable))) {
        seekTo(previousWindowIndex, C.TIME_UNSET);
    } else {
        seekTo(0);
    }
}
 
開發者ID:yangchaojiang,項目名稱:yjPlay,代碼行數:17,代碼來源:PlaybackControlView.java

示例6: seekToTimeBarPosition

import com.google.android.exoplayer2.Timeline; //導入依賴的package包/類
private void seekToTimeBarPosition(long positionMs) {
    int windowIndex;
    Timeline timeline = player.getCurrentTimeline();
    if (multiWindowTimeBar && !timeline.isEmpty()) {
        int windowCount = timeline.getWindowCount();
        windowIndex = 0;
        while (true) {
            long windowDurationMs = timeline.getWindow(windowIndex, window).getDurationMs();
            if (positionMs < windowDurationMs) {
                break;
            } else if (windowIndex == windowCount - 1) {
                // Seeking past the end of the last window should seek to the end of the timeline.
                positionMs = windowDurationMs;
                break;
            }
            positionMs -= windowDurationMs;
            windowIndex++;
        }
    } else {
        windowIndex = player.getCurrentWindowIndex();
    }
    seekTo(windowIndex, positionMs);
}
 
開發者ID:yangchaojiang,項目名稱:yjPlay,代碼行數:24,代碼來源:PlaybackControlView.java

示例7: previous

import com.google.android.exoplayer2.Timeline; //導入依賴的package包/類
/**
     * 上一首
     */
    private void previous() {
        Timeline timeline = player.getCurrentTimeline();
        if (timeline.isEmpty()) {
            return;
        }
        int windowIndex = player.getCurrentWindowIndex();
        timeline.getWindow(windowIndex, window);
        int previousWindowIndex = timeline.getPreviousWindowIndex(windowIndex, player.getRepeatMode());
        Timber.e("previousWindowIndex:" + previousWindowIndex);
        Timber.e("getCurrentPosition:" + player.getCurrentPosition());
        Timber.e("isDynamic:" + window.isDynamic);
        Timber.e("isSeekable:" + window.isSeekable);
        Timber.e("TIME_UNSET:" + C.TIME_UNSET);
        Timber.e("TIME_UNSET:" + C.TIME_UNSET);
        if (previousWindowIndex != C.INDEX_UNSET) {
            player.seekTo(previousWindowIndex, C.TIME_UNSET);
        } else {
            Timber.e("seekTo(0):");
            Timber.e("已經是第一首");
//            player.seekTo(0);
        }
    }
 
開發者ID:ChangWeiBa,項目名稱:AesExoPlayer,代碼行數:26,代碼來源:TestPlayerActivity.java

示例8: next

import com.google.android.exoplayer2.Timeline; //導入依賴的package包/類
/**
 * 下一首
 */
private void next() {
    Timeline timeline = player.getCurrentTimeline();
    if (timeline.isEmpty()) {
        return;
    }

    int windowIndex = player.getCurrentWindowIndex();
    Timber.e("windowIndex:" + windowIndex);
    int nextWindowIndex = timeline.getNextWindowIndex(windowIndex, player.getRepeatMode());
    Timber.e("nextWindowIndex:" + nextWindowIndex);
    Timber.e("isDynamic:" + window.isDynamic);
    Timber.e("TIME_UNSET:" + C.TIME_UNSET);
    if (nextWindowIndex != C.INDEX_UNSET) {
        player.seekTo(nextWindowIndex, C.TIME_UNSET);
    } else if (timeline.getWindow(windowIndex, window, false).isDynamic) {
        player.seekTo(windowIndex, C.TIME_UNSET);
        Timber.e("已經最後一首");

    }
}
 
開發者ID:ChangWeiBa,項目名稱:AesExoPlayer,代碼行數:24,代碼來源:TestPlayerActivity.java

示例9: onTimelineChanged

import com.google.android.exoplayer2.Timeline; //導入依賴的package包/類
@Override
public void onTimelineChanged(Timeline timeline, Object manifest) {
  int periodCount = timeline.getPeriodCount();
  int windowCount = timeline.getWindowCount();
  Log.d(TAG, "sourceInfo [periodCount=" + periodCount + ", windowCount=" + windowCount);
  for (int i = 0; i < Math.min(periodCount, MAX_TIMELINE_ITEM_LINES); i++) {
    timeline.getPeriod(i, period);
    Log.d(TAG, "  " +  "period [" + getTimeString(period.getDurationMs()) + "]");
  }
  if (periodCount > MAX_TIMELINE_ITEM_LINES) {
    Log.d(TAG, "  ...");
  }
  for (int i = 0; i < Math.min(windowCount, MAX_TIMELINE_ITEM_LINES); i++) {
    timeline.getWindow(i, window);
    Log.d(TAG, "  " +  "window [" + getTimeString(window.getDurationMs()) + ", "
        + window.isSeekable + ", " + window.isDynamic + "]");
  }
  if (windowCount > MAX_TIMELINE_ITEM_LINES) {
    Log.d(TAG, "  ...");
  }
  Log.d(TAG, "]");
}
 
開發者ID:Tubitv,項目名稱:TubiPlayer,代碼行數:23,代碼來源:EventLogger.java

示例10: onTimelineChanged

import com.google.android.exoplayer2.Timeline; //導入依賴的package包/類
@Override
public void onTimelineChanged(Timeline timeline, Object manifest) {
  if (timeline == null) {
    return;
  }
  int periodCount = timeline.getPeriodCount();
  int windowCount = timeline.getWindowCount();
  Log.d(TAG, "sourceInfo [periodCount=" + periodCount + ", windowCount=" + windowCount);
  for (int i = 0; i < Math.min(periodCount, MAX_TIMELINE_ITEM_LINES); i++) {
    timeline.getPeriod(i, period);
    Log.d(TAG, "  " +  "period [" + getTimeString(period.getDurationMs()) + "]");
  }
  if (periodCount > MAX_TIMELINE_ITEM_LINES) {
    Log.d(TAG, "  ...");
  }
  for (int i = 0; i < Math.min(windowCount, MAX_TIMELINE_ITEM_LINES); i++) {
    timeline.getWindow(i, window);
    Log.d(TAG, "  " +  "window [" + getTimeString(window.getDurationMs()) + ", "
        + window.isSeekable + ", " + window.isDynamic + "]");
  }
  if (windowCount > MAX_TIMELINE_ITEM_LINES) {
    Log.d(TAG, "  ...");
  }
  Log.d(TAG, "]");
}
 
開發者ID:ashwanijanghu,項目名稱:ExoPlayer-Offline,代碼行數:26,代碼來源:EventLogger.java

示例11: ClippingTimeline

import com.google.android.exoplayer2.Timeline; //導入依賴的package包/類
/**
 * Creates a new clipping timeline that wraps the specified timeline.
 *
 * @param timeline The timeline to clip.
 * @param startUs The number of microseconds to clip from the start of {@code timeline}.
 * @param endUs The end position in microseconds for the clipped timeline relative to the start
 *     of {@code timeline}, or {@link C#TIME_END_OF_SOURCE} to clip no samples from the end.
 */
public ClippingTimeline(Timeline timeline, long startUs, long endUs) {
  Assertions.checkArgument(timeline.getWindowCount() == 1);
  Assertions.checkArgument(timeline.getPeriodCount() == 1);
  Window window = timeline.getWindow(0, new Window(), false);
  Assertions.checkArgument(!window.isDynamic);
  long resolvedEndUs = endUs == C.TIME_END_OF_SOURCE ? window.durationUs : endUs;
  if (window.durationUs != C.TIME_UNSET) {
    Assertions.checkArgument(startUs == 0 || window.isSeekable);
    Assertions.checkArgument(resolvedEndUs <= window.durationUs);
    Assertions.checkArgument(startUs <= resolvedEndUs);
  }
  Period period = timeline.getPeriod(0, new Period());
  Assertions.checkArgument(period.getPositionInWindowUs() == 0);
  this.timeline = timeline;
  this.startUs = startUs;
  this.endUs = resolvedEndUs;
}
 
開發者ID:sanjaysingh1990,項目名稱:Exoplayer2Radio,代碼行數:26,代碼來源:ClippingMediaSource.java

示例12: LoopingTimeline

import com.google.android.exoplayer2.Timeline; //導入依賴的package包/類
public LoopingTimeline(Timeline childTimeline, int loopCount) {
  this.childTimeline = childTimeline;
  childPeriodCount = childTimeline.getPeriodCount();
  childWindowCount = childTimeline.getWindowCount();
  // This is the maximum number of loops that can be performed without exceeding
  // MAX_EXPOSED_PERIODS periods.
  int maxLoopCount = MAX_EXPOSED_PERIODS / childPeriodCount;
  if (loopCount > maxLoopCount) {
    if (loopCount != Integer.MAX_VALUE) {
      Log.w(TAG, "Capped loops to avoid overflow: " + loopCount + " -> " + maxLoopCount);
    }
    this.loopCount = maxLoopCount;
  } else {
    this.loopCount = loopCount;
  }
}
 
開發者ID:sanjaysingh1990,項目名稱:Exoplayer2Radio,代碼行數:17,代碼來源:LoopingMediaSource.java

示例13: handleSourceInfoRefreshed

import com.google.android.exoplayer2.Timeline; //導入依賴的package包/類
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());
}
 
開發者ID:sanjaysingh1990,項目名稱:Exoplayer2Radio,代碼行數:22,代碼來源:ConcatenatingMediaSource.java

示例14: ConcatenatedTimeline

import com.google.android.exoplayer2.Timeline; //導入依賴的package包/類
public ConcatenatedTimeline(Timeline[] timelines) {
  int[] sourcePeriodOffsets = new int[timelines.length];
  int[] sourceWindowOffsets = new int[timelines.length];
  long periodCount = 0;
  int windowCount = 0;
  for (int i = 0; i < timelines.length; i++) {
    Timeline timeline = timelines[i];
    periodCount += timeline.getPeriodCount();
    Assertions.checkState(periodCount <= Integer.MAX_VALUE,
        "ConcatenatingMediaSource children contain too many periods");
    sourcePeriodOffsets[i] = (int) periodCount;
    windowCount += timeline.getWindowCount();
    sourceWindowOffsets[i] = windowCount;
  }
  this.timelines = timelines;
  this.sourcePeriodOffsets = sourcePeriodOffsets;
  this.sourceWindowOffsets = sourceWindowOffsets;
}
 
開發者ID:sanjaysingh1990,項目名稱:Exoplayer2Radio,代碼行數:19,代碼來源:ConcatenatingMediaSource.java

示例15: handleSourceInfoRefreshed

import com.google.android.exoplayer2.Timeline; //導入依賴的package包/類
private void handleSourceInfoRefreshed(int sourceIndex, Timeline timeline, Object manifest) {
  if (mergeError == null) {
    mergeError = checkTimelineMerges(timeline);
  }
  if (mergeError != null) {
    return;
  }
  pendingTimelineSources.remove(mediaSources[sourceIndex]);
  if (sourceIndex == 0) {
    primaryTimeline = timeline;
    primaryManifest = manifest;
  }
  if (pendingTimelineSources.isEmpty()) {
    listener.onSourceInfoRefreshed(primaryTimeline, primaryManifest);
  }
}
 
開發者ID:sanjaysingh1990,項目名稱:Exoplayer2Radio,代碼行數:17,代碼來源:MergingMediaSource.java


注:本文中的com.google.android.exoplayer2.Timeline類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。