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


Java Timeline.getWindow方法代碼示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: pause

import com.google.android.exoplayer2.Timeline; //導入方法依賴的package包/類
public void pause() {
    if (player == null) {
        return;
    }

    if (player.getPlayWhenReady()) {

        Timeline currentTimeline = player.getCurrentTimeline();
        boolean haveNonEmptyTimeline = currentTimeline != null && !currentTimeline.isEmpty();
        if (haveNonEmptyTimeline && currentTimeline.getWindow(playerWindow, window).isSeekable) {
            playerPosition = player.getCurrentPosition();
        }

        player.setPlayWhenReady(false);

        isPauseFromUser = false;

    } else {
        isPauseFromUser = true;
    }
}
 
開發者ID:JarvanMo,項目名稱:ExoPlayerVideoView,代碼行數:22,代碼來源:ExoVideoView.java

示例10: updateNavigation

import com.google.android.exoplayer2.Timeline; //導入方法依賴的package包/類
private void updateNavigation() {

        if (!isVisible() || !isAttachedToWindow) {
            return;
        }
        Timeline currentTimeline = player != null ? player.getCurrentTimeline() : null;
        boolean haveNonEmptyTimeline = currentTimeline != null && !currentTimeline.isEmpty();
        boolean enableNext = false;
        if (haveNonEmptyTimeline) {
            int currentWindowIndex = player.getCurrentWindowIndex();
            currentTimeline.getWindow(currentWindowIndex, currentWindow);
//            enablePrevious = currentWindowIndex > 0 || isSeekable || !currentWindow.isDynamic;
            enableNext = (currentWindowIndex < currentTimeline.getWindowCount() - 1)
                    || currentWindow.isDynamic;
        }


        setButtonEnabled(enableNext, nextLandscape);

    }
 
開發者ID:JarvanMo,項目名稱:ExoPlayerVideoView,代碼行數:21,代碼來源:ExoVideoPlaybackControlView.java

示例11: onTimelineChanged

import com.google.android.exoplayer2.Timeline; //導入方法依賴的package包/類
@Override
public void onTimelineChanged(Timeline timeline, Object manifest) {
    isTimelineStatic = !timeline.isEmpty()
            && !timeline.getWindow(timeline.getWindowCount() - 1, window).isDynamic;


    if (manifest instanceof HlsManifest) {
        HlsManifest hlsManifest = (HlsManifest) manifest;
        isHls = !hlsManifest.mediaPlaylist.hasEndTag && hlsManifest.mediaPlaylist.playlistType == HlsMediaPlaylist.PLAYLIST_TYPE_UNKNOWN;
        Log.e("time->",stringForTime(hlsManifest.mediaPlaylist.startOffsetUs));
    }


    updateNavigation();
    updateProgress();

}
 
開發者ID:JarvanMo,項目名稱:ExoPlayerVideoView,代碼行數:18,代碼來源:ExoVideoPlaybackControlView.java

示例12: updateNavigation

import com.google.android.exoplayer2.Timeline; //導入方法依賴的package包/類
private void updateNavigation() {
  if (!isVisible() || !isAttachedToWindow) {
    return;
  }
  Timeline currentTimeline = player != null ? player.getCurrentTimeline() : null;
  boolean haveNonEmptyTimeline = currentTimeline != null && !currentTimeline.isEmpty();
  boolean isSeekable = false;
  boolean enablePrevious = false;
  boolean enableNext = false;
  if (haveNonEmptyTimeline) {
    int currentWindowIndex = player.getCurrentWindowIndex();
    currentTimeline.getWindow(currentWindowIndex, currentWindow);
    isSeekable = currentWindow.isSeekable;
    enablePrevious = currentWindowIndex > 0 || isSeekable || !currentWindow.isDynamic;
    enableNext = (currentWindowIndex < currentTimeline.getWindowCount() - 1)
        || currentWindow.isDynamic;
  }
  setButtonEnabled(enablePrevious , previousButton);
  setButtonEnabled(enableNext, nextButton);
  setButtonEnabled(fastForwardMs > 0 && isSeekable, fastForwardButton);
  setButtonEnabled(rewindMs > 0 && isSeekable, rewindButton);
  if (progressBar != null) {
    progressBar.setEnabled(isSeekable);
  }
}
 
開發者ID:jcodeing,項目名稱:K-Sonic,代碼行數:26,代碼來源:PlaybackControlView.java

示例13: 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:AndroidTips,項目名稱:MDVideo,代碼行數:26,代碼來源:EventLogger.java

示例14: updateNavigation

import com.google.android.exoplayer2.Timeline; //導入方法依賴的package包/類
private void updateNavigation() {
    if (!isVisible() || !isAttachedToWindow) {
      return;
    }
    Timeline currentTimeline = player != null ? player.getCurrentTimeline() : null;
    boolean haveTimeline = currentTimeline != null;
    boolean isSeekable = false;
    boolean enablePrevious = false;
    boolean enableNext = false;
    if (haveTimeline) {
      int currentWindowIndex = player.getCurrentWindowIndex();
      currentTimeline.getWindow(currentWindowIndex, currentWindow);
      isSeekable = currentWindow.isSeekable;
      enablePrevious = currentWindowIndex > 0 || isSeekable || !currentWindow.isDynamic;
      enableNext = (currentWindowIndex < currentTimeline.getWindowCount() - 1)
          || currentWindow.isDynamic;
    }
//    setButtonEnabled(enablePrevious , previousButton);
//    setButtonEnabled(enableNext, nextButton);
//    setButtonEnabled(fastForwardMs > 0 && isSeekable, fastForwardButton);
//    setButtonEnabled(rewindMs > 0 && isSeekable, rewindButton);
    progressBar.setEnabled(isSeekable);
  }
 
開發者ID:zhanglibin123488,項目名稱:videoPickPlayer,代碼行數:24,代碼來源:PlaybackControlView.java

示例15: next

import com.google.android.exoplayer2.Timeline; //導入方法依賴的package包/類
public void next() {
    Timeline timeline = player.getCurrentTimeline();
    if (timeline.isEmpty()) {
        return;
    }
    int windowIndex = player.getCurrentWindowIndex();
    int nextWindowIndex = player.getNextWindowIndex();
    if (nextWindowIndex != C.INDEX_UNSET) {
        seekTo(nextWindowIndex, C.TIME_UNSET);
    } else if (timeline.getWindow(windowIndex, window, false).isDynamic) {
        seekTo(windowIndex, C.TIME_UNSET);
    }
}
 
開發者ID:yangchaojiang,項目名稱:yjPlay,代碼行數:14,代碼來源:PlaybackControlView.java


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