Java Code Examples for com.google.android.exoplayer2.util.Util#getMediaDurationForPlayoutDuration()
The following examples show how to use
com.google.android.exoplayer2.util.Util#getMediaDurationForPlayoutDuration() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultLoadControl.java From MediaSDK with Apache License 2.0 | 6 votes |
@Override public boolean shouldContinueLoading(long bufferedDurationUs, float playbackSpeed) { boolean targetBufferSizeReached = allocator.getTotalBytesAllocated() >= targetBufferSize; long minBufferUs = hasVideo ? minBufferVideoUs : minBufferAudioUs; if (playbackSpeed > 1) { // The playback speed is faster than real time, so scale up the minimum required media // duration to keep enough media buffered for a playout duration of minBufferUs. long mediaDurationMinBufferUs = Util.getMediaDurationForPlayoutDuration(minBufferUs, playbackSpeed); minBufferUs = Math.min(mediaDurationMinBufferUs, maxBufferUs); } if (bufferedDurationUs < minBufferUs) { isBuffering = prioritizeTimeOverSizeThresholds || !targetBufferSizeReached; } else if (bufferedDurationUs >= maxBufferUs || targetBufferSizeReached) { isBuffering = false; } // Else don't change the buffering state return isBuffering; }
Example 2
Source File: DefaultLoadControl.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public boolean shouldContinueLoading(long bufferedDurationUs, float playbackSpeed) { boolean targetBufferSizeReached = allocator.getTotalBytesAllocated() >= targetBufferSize; boolean wasBuffering = isBuffering; long minBufferUs = this.minBufferUs; if (playbackSpeed > 1) { // The playback speed is faster than real time, so scale up the minimum required media // duration to keep enough media buffered for a playout duration of minBufferUs. long mediaDurationMinBufferUs = Util.getMediaDurationForPlayoutDuration(minBufferUs, playbackSpeed); minBufferUs = Math.min(mediaDurationMinBufferUs, maxBufferUs); } if (bufferedDurationUs < minBufferUs) { isBuffering = prioritizeTimeOverSizeThresholds || !targetBufferSizeReached; } else if (bufferedDurationUs > maxBufferUs || targetBufferSizeReached) { isBuffering = false; } // Else don't change the buffering state if (priorityTaskManager != null && isBuffering != wasBuffering) { if (isBuffering) { priorityTaskManager.add(C.PRIORITY_PLAYBACK); } else { priorityTaskManager.remove(C.PRIORITY_PLAYBACK); } } return isBuffering; }
Example 3
Source File: DefaultLoadControl.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public boolean shouldContinueLoading(long bufferedDurationUs, float playbackSpeed) { boolean targetBufferSizeReached = allocator.getTotalBytesAllocated() >= targetBufferSize; boolean wasBuffering = isBuffering; long minBufferUs = this.minBufferUs; if (playbackSpeed > 1) { // The playback speed is faster than real time, so scale up the minimum required media // duration to keep enough media buffered for a playout duration of minBufferUs. long mediaDurationMinBufferUs = Util.getMediaDurationForPlayoutDuration(minBufferUs, playbackSpeed); minBufferUs = Math.min(mediaDurationMinBufferUs, maxBufferUs); } if (bufferedDurationUs < minBufferUs) { isBuffering = prioritizeTimeOverSizeThresholds || !targetBufferSizeReached; } else if (bufferedDurationUs > maxBufferUs || targetBufferSizeReached) { isBuffering = false; } // Else don't change the buffering state if (priorityTaskManager != null && isBuffering != wasBuffering) { if (isBuffering) { priorityTaskManager.add(C.PRIORITY_PLAYBACK); } else { priorityTaskManager.remove(C.PRIORITY_PLAYBACK); } } return isBuffering; }
Example 4
Source File: DefaultLoadControl.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
@Override public boolean shouldContinueLoading(long bufferedDurationUs, float playbackSpeed) { boolean targetBufferSizeReached = allocator.getTotalBytesAllocated() >= targetBufferSize; long minBufferUs = hasVideo ? minBufferVideoUs : minBufferAudioUs; if (playbackSpeed > 1) { // The playback speed is faster than real time, so scale up the minimum required media // duration to keep enough media buffered for a playout duration of minBufferUs. long mediaDurationMinBufferUs = Util.getMediaDurationForPlayoutDuration(minBufferUs, playbackSpeed); minBufferUs = Math.min(mediaDurationMinBufferUs, maxBufferUs); } if (bufferedDurationUs < minBufferUs) { isBuffering = prioritizeTimeOverSizeThresholds || !targetBufferSizeReached; } else if (bufferedDurationUs >= maxBufferUs || targetBufferSizeReached) { isBuffering = false; } // Else don't change the buffering state return isBuffering; }
Example 5
Source File: DefaultLoadControl.java From Telegram with GNU General Public License v2.0 | 6 votes |
@Override public boolean shouldContinueLoading(long bufferedDurationUs, float playbackSpeed) { boolean targetBufferSizeReached = allocator.getTotalBytesAllocated() >= targetBufferSize; long minBufferUs = hasVideo ? minBufferVideoUs : minBufferAudioUs; if (playbackSpeed > 1) { // The playback speed is faster than real time, so scale up the minimum required media // duration to keep enough media buffered for a playout duration of minBufferUs. long mediaDurationMinBufferUs = Util.getMediaDurationForPlayoutDuration(minBufferUs, playbackSpeed); minBufferUs = Math.min(mediaDurationMinBufferUs, maxBufferUs); } if (bufferedDurationUs < minBufferUs) { isBuffering = prioritizeTimeOverSizeThresholds || !targetBufferSizeReached; } else if (bufferedDurationUs >= maxBufferUs || targetBufferSizeReached) { isBuffering = false; } // Else don't change the buffering state return isBuffering; }
Example 6
Source File: DefaultAudioSink.java From MediaSDK with Apache License 2.0 | 5 votes |
private long applySpeedup(long positionUs) { @Nullable PlaybackParametersCheckpoint checkpoint = null; while (!playbackParametersCheckpoints.isEmpty() && positionUs >= playbackParametersCheckpoints.getFirst().positionUs) { checkpoint = playbackParametersCheckpoints.remove(); } if (checkpoint != null) { // We are playing (or about to play) media with the new playback parameters, so update them. playbackParameters = checkpoint.playbackParameters; playbackParametersPositionUs = checkpoint.positionUs; playbackParametersOffsetUs = checkpoint.mediaTimeUs - startMediaTimeUs; } if (playbackParameters.speed == 1f) { return positionUs + playbackParametersOffsetUs - playbackParametersPositionUs; } if (playbackParametersCheckpoints.isEmpty()) { return playbackParametersOffsetUs + audioProcessorChain.getMediaDuration(positionUs - playbackParametersPositionUs); } // We are playing data at a previous playback speed, so fall back to multiplying by the speed. return playbackParametersOffsetUs + Util.getMediaDurationForPlayoutDuration( positionUs - playbackParametersPositionUs, playbackParameters.speed); }
Example 7
Source File: DefaultAudioSink.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private long applySpeedup(long positionUs) { @Nullable PlaybackParametersCheckpoint checkpoint = null; while (!playbackParametersCheckpoints.isEmpty() && positionUs >= playbackParametersCheckpoints.getFirst().positionUs) { checkpoint = playbackParametersCheckpoints.remove(); } if (checkpoint != null) { // We are playing (or about to play) media with the new playback parameters, so update them. playbackParameters = checkpoint.playbackParameters; playbackParametersPositionUs = checkpoint.positionUs; playbackParametersOffsetUs = checkpoint.mediaTimeUs - startMediaTimeUs; } if (playbackParameters.speed == 1f) { return positionUs + playbackParametersOffsetUs - playbackParametersPositionUs; } if (playbackParametersCheckpoints.isEmpty()) { return playbackParametersOffsetUs + audioProcessorChain.getMediaDuration(positionUs - playbackParametersPositionUs); } // We are playing data at a previous playback speed, so fall back to multiplying by the speed. return playbackParametersOffsetUs + Util.getMediaDurationForPlayoutDuration( positionUs - playbackParametersPositionUs, playbackParameters.speed); }
Example 8
Source File: DefaultAudioSink.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private long applySpeedup(long positionUs) { @Nullable PlaybackParametersCheckpoint checkpoint = null; while (!playbackParametersCheckpoints.isEmpty() && positionUs >= playbackParametersCheckpoints.getFirst().positionUs) { checkpoint = playbackParametersCheckpoints.remove(); } if (checkpoint != null) { // We are playing (or about to play) media with the new playback parameters, so update them. playbackParameters = checkpoint.playbackParameters; playbackParametersPositionUs = checkpoint.positionUs; playbackParametersOffsetUs = checkpoint.mediaTimeUs - startMediaTimeUs; } if (playbackParameters.speed == 1f) { return positionUs + playbackParametersOffsetUs - playbackParametersPositionUs; } if (playbackParametersCheckpoints.isEmpty()) { return playbackParametersOffsetUs + audioProcessorChain.getMediaDuration(positionUs - playbackParametersPositionUs); } // We are playing data at a previous playback speed, so fall back to multiplying by the speed. return playbackParametersOffsetUs + Util.getMediaDurationForPlayoutDuration( positionUs - playbackParametersPositionUs, playbackParameters.speed); }
Example 9
Source File: DefaultAudioSink.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private long applySpeedup(long positionUs) { @Nullable PlaybackParametersCheckpoint checkpoint = null; while (!playbackParametersCheckpoints.isEmpty() && positionUs >= playbackParametersCheckpoints.getFirst().positionUs) { checkpoint = playbackParametersCheckpoints.remove(); } if (checkpoint != null) { // We are playing (or about to play) media with the new playback parameters, so update them. playbackParameters = checkpoint.playbackParameters; playbackParametersPositionUs = checkpoint.positionUs; playbackParametersOffsetUs = checkpoint.mediaTimeUs - startMediaTimeUs; } if (playbackParameters.speed == 1f) { return positionUs + playbackParametersOffsetUs - playbackParametersPositionUs; } if (playbackParametersCheckpoints.isEmpty()) { return playbackParametersOffsetUs + audioProcessorChain.getMediaDuration(positionUs - playbackParametersPositionUs); } // We are playing data at a previous playback speed, so fall back to multiplying by the speed. return playbackParametersOffsetUs + Util.getMediaDurationForPlayoutDuration( positionUs - playbackParametersPositionUs, playbackParameters.speed); }
Example 10
Source File: DefaultAudioSink.java From Telegram with GNU General Public License v2.0 | 5 votes |
private long applySpeedup(long positionUs) { @Nullable PlaybackParametersCheckpoint checkpoint = null; while (!playbackParametersCheckpoints.isEmpty() && positionUs >= playbackParametersCheckpoints.getFirst().positionUs) { checkpoint = playbackParametersCheckpoints.remove(); } if (checkpoint != null) { // We are playing (or about to play) media with the new playback parameters, so update them. playbackParameters = checkpoint.playbackParameters; playbackParametersPositionUs = checkpoint.positionUs; playbackParametersOffsetUs = checkpoint.mediaTimeUs - startMediaTimeUs; } if (playbackParameters.speed == 1f) { return positionUs + playbackParametersOffsetUs - playbackParametersPositionUs; } if (playbackParametersCheckpoints.isEmpty()) { return playbackParametersOffsetUs + audioProcessorChain.getMediaDuration(positionUs - playbackParametersPositionUs); } // We are playing data at a previous playback speed, so fall back to multiplying by the speed. return playbackParametersOffsetUs + Util.getMediaDurationForPlayoutDuration( positionUs - playbackParametersPositionUs, playbackParameters.speed); }