本文整理匯總了Java中com.google.android.exoplayer2.Timeline.isEmpty方法的典型用法代碼示例。如果您正苦於以下問題:Java Timeline.isEmpty方法的具體用法?Java Timeline.isEmpty怎麽用?Java Timeline.isEmpty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.android.exoplayer2.Timeline
的用法示例。
在下文中一共展示了Timeline.isEmpty方法的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();
}
示例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);
}
}
示例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);
}
}
示例4: 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);
}
示例5: 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);
}
}
示例6: 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("已經最後一首");
}
}
示例7: 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;
}
}
示例8: 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);
}
示例9: 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();
}
示例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 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);
}
}
示例11: releasePlayer
import com.google.android.exoplayer2.Timeline; //導入方法依賴的package包/類
private void releasePlayer() {
if (player != null) {
debugViewHelper.stop();
debugViewHelper = null;
shouldAutoPlay = player.getPlayWhenReady();
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;
trackSelectionHelper = null;
eventLogger = null;
}
}
示例12: onTimelineChanged
import com.google.android.exoplayer2.Timeline; //導入方法依賴的package包/類
@Override
public void onTimelineChanged(Timeline timeline, Object manifest) {
if (timeline.isEmpty()) {
// The player is being re-prepared and this source will be released.
return;
}
Assertions.checkArgument(timeline.getPeriodCount() == 1);
this.timeline = timeline;
long contentDurationUs = timeline.getPeriod(0, period).durationUs;
contentDurationMs = C.usToMs(contentDurationUs);
if (contentDurationUs != C.TIME_UNSET) {
adPlaybackState.contentDurationUs = contentDurationUs;
}
updateImaStateForPlayerState();
}
示例13: 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);
}
}
示例14: canSeek
import com.google.android.exoplayer2.Timeline; //導入方法依賴的package包/類
private boolean canSeek() {
Timeline currentTimeline = player != null ? player.getCurrentTimeline() : null;
boolean haveNonEmptyTimeline = currentTimeline != null && !currentTimeline.isEmpty();
boolean isSeekable = false;
if (haveNonEmptyTimeline) {
int currentWindowIndex = player.getCurrentWindowIndex();
currentTimeline.getWindow(currentWindowIndex, currentWindow);
isSeekable = currentWindow.isSeekable;
// enablePrevious = currentWindowIndex > 0 || isSeekable || !currentWindow.isDynamic;
}
return isSeekable && isTimelineStatic;
}
示例15: previous
import com.google.android.exoplayer2.Timeline; //導入方法依賴的package包/類
private void previous() {
Timeline currentTimeline = player.getCurrentTimeline();
if (currentTimeline.isEmpty()) {
return;
}
int currentWindowIndex = player.getCurrentWindowIndex();
currentTimeline.getWindow(currentWindowIndex, currentWindow);
if (currentWindowIndex > 0 && (player.getCurrentPosition() <= MAX_POSITION_FOR_SEEK_TO_PREVIOUS
|| (currentWindow.isDynamic && !currentWindow.isSeekable))) {
seekTo(currentWindowIndex - 1, C.TIME_UNSET);
} else {
seekTo(0);
}
}