Transition ExoPlayer to use longs for ms timestamps.
This commit is contained in:
parent
d85f4abb2b
commit
e4b35e884a
@ -70,7 +70,7 @@ public class FullPlayerActivity extends Activity implements SurfaceHolder.Callba
|
||||
private boolean playerNeedsPrepare;
|
||||
|
||||
private boolean autoPlay = true;
|
||||
private int playerPosition;
|
||||
private long playerPosition;
|
||||
private boolean enableBackgroundAudio = false;
|
||||
|
||||
private Uri contentUri;
|
||||
|
@ -310,7 +310,7 @@ public class DemoPlayer implements ExoPlayer.Listener, ChunkSampleSource.EventLi
|
||||
player.setPlayWhenReady(playWhenReady);
|
||||
}
|
||||
|
||||
public void seekTo(int positionMs) {
|
||||
public void seekTo(long positionMs) {
|
||||
player.seekTo(positionMs);
|
||||
}
|
||||
|
||||
@ -339,11 +339,11 @@ public class DemoPlayer implements ExoPlayer.Listener, ChunkSampleSource.EventLi
|
||||
return playerState;
|
||||
}
|
||||
|
||||
public int getCurrentPosition() {
|
||||
public long getCurrentPosition() {
|
||||
return player.getCurrentPosition();
|
||||
}
|
||||
|
||||
public int getDuration() {
|
||||
public long getDuration() {
|
||||
return player.getDuration();
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ public class SimplePlayerActivity extends Activity implements SurfaceHolder.Call
|
||||
private MediaCodecVideoTrackRenderer videoRenderer;
|
||||
|
||||
private boolean autoPlay = true;
|
||||
private int playerPosition;
|
||||
private long playerPosition;
|
||||
|
||||
private Uri contentUri;
|
||||
private int contentType;
|
||||
|
@ -229,7 +229,7 @@ public interface ExoPlayer {
|
||||
/**
|
||||
* Represents an unknown time or duration.
|
||||
*/
|
||||
public static final int UNKNOWN_TIME = -1;
|
||||
public static final long UNKNOWN_TIME = -1;
|
||||
|
||||
/**
|
||||
* Gets the {@link Looper} associated with the playback thread.
|
||||
@ -313,7 +313,7 @@ public interface ExoPlayer {
|
||||
*
|
||||
* @param positionMs The seek position.
|
||||
*/
|
||||
public void seekTo(int positionMs);
|
||||
public void seekTo(long positionMs);
|
||||
|
||||
/**
|
||||
* Stops playback. Use {@code setPlayWhenReady(false)} rather than this method if the intention
|
||||
@ -363,14 +363,14 @@ public interface ExoPlayer {
|
||||
* @return The duration of the track in milliseconds, or {@link ExoPlayer#UNKNOWN_TIME} if the
|
||||
* duration is not known.
|
||||
*/
|
||||
public int getDuration();
|
||||
public long getDuration();
|
||||
|
||||
/**
|
||||
* Gets the current playback position in milliseconds.
|
||||
*
|
||||
* @return The current playback position in milliseconds.
|
||||
*/
|
||||
public int getCurrentPosition();
|
||||
public long getCurrentPosition();
|
||||
|
||||
/**
|
||||
* Gets an estimate of the absolute position in milliseconds up to which data is buffered.
|
||||
@ -378,7 +378,7 @@ public interface ExoPlayer {
|
||||
* @return An estimate of the absolute position in milliseconds up to which data is buffered,
|
||||
* or {@link ExoPlayer#UNKNOWN_TIME} if no estimate is available.
|
||||
*/
|
||||
public int getBufferedPosition();
|
||||
public long getBufferedPosition();
|
||||
|
||||
/**
|
||||
* Gets an estimate of the percentage into the media up to which data is buffered.
|
||||
|
@ -130,7 +130,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void seekTo(int positionMs) {
|
||||
public void seekTo(long positionMs) {
|
||||
internalPlayer.seekTo(positionMs);
|
||||
}
|
||||
|
||||
@ -156,26 +156,26 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDuration() {
|
||||
public long getDuration() {
|
||||
return internalPlayer.getDuration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCurrentPosition() {
|
||||
public long getCurrentPosition() {
|
||||
return internalPlayer.getCurrentPosition();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBufferedPosition() {
|
||||
public long getBufferedPosition() {
|
||||
return internalPlayer.getBufferedPosition();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBufferedPercentage() {
|
||||
int bufferedPosition = getBufferedPosition();
|
||||
int duration = getDuration();
|
||||
long bufferedPosition = getBufferedPosition();
|
||||
long duration = getDuration();
|
||||
return bufferedPosition == ExoPlayer.UNKNOWN_TIME || duration == ExoPlayer.UNKNOWN_TIME ? 0
|
||||
: (duration == 0 ? 100 : (bufferedPosition * 100) / duration);
|
||||
: (int) (duration == 0 ? 100 : (bufferedPosition * 100) / duration);
|
||||
}
|
||||
|
||||
// Not private so it can be called from an inner class without going through a thunk method.
|
||||
|
@ -117,18 +117,18 @@ import java.util.List;
|
||||
return internalPlaybackThread.getLooper();
|
||||
}
|
||||
|
||||
public int getCurrentPosition() {
|
||||
return (int) (positionUs / 1000);
|
||||
public long getCurrentPosition() {
|
||||
return positionUs / 1000;
|
||||
}
|
||||
|
||||
public int getBufferedPosition() {
|
||||
public long getBufferedPosition() {
|
||||
return bufferedPositionUs == TrackRenderer.UNKNOWN_TIME_US ? ExoPlayer.UNKNOWN_TIME
|
||||
: (int) (bufferedPositionUs / 1000);
|
||||
: bufferedPositionUs / 1000;
|
||||
}
|
||||
|
||||
public int getDuration() {
|
||||
public long getDuration() {
|
||||
return durationUs == TrackRenderer.UNKNOWN_TIME_US ? ExoPlayer.UNKNOWN_TIME
|
||||
: (int) (durationUs / 1000);
|
||||
: durationUs / 1000;
|
||||
}
|
||||
|
||||
public void prepare(TrackRenderer... renderers) {
|
||||
@ -139,8 +139,8 @@ import java.util.List;
|
||||
handler.obtainMessage(MSG_SET_PLAY_WHEN_READY, playWhenReady ? 1 : 0, 0).sendToTarget();
|
||||
}
|
||||
|
||||
public void seekTo(int positionMs) {
|
||||
handler.obtainMessage(MSG_SEEK_TO, positionMs, 0).sendToTarget();
|
||||
public void seekTo(long positionMs) {
|
||||
handler.obtainMessage(MSG_SEEK_TO, positionMs).sendToTarget();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
@ -204,7 +204,7 @@ import java.util.List;
|
||||
return true;
|
||||
}
|
||||
case MSG_SEEK_TO: {
|
||||
seekToInternal(msg.arg1);
|
||||
seekToInternal((Long) msg.obj);
|
||||
return true;
|
||||
}
|
||||
case MSG_STOP: {
|
||||
@ -453,7 +453,7 @@ import java.util.List;
|
||||
}
|
||||
}
|
||||
|
||||
private void seekToInternal(int positionMs) throws ExoPlaybackException {
|
||||
private void seekToInternal(long positionMs) throws ExoPlaybackException {
|
||||
rebuffering = false;
|
||||
positionUs = positionMs * 1000L;
|
||||
mediaClock.stop();
|
||||
|
@ -855,8 +855,8 @@ public final class FragmentedMp4Extractor implements Extractor {
|
||||
|
||||
out.initTables(sampleCount);
|
||||
int[] sampleSizeTable = out.sampleSizeTable;
|
||||
int[] sampleDecodingTimeTable = out.sampleDecodingTimeTable;
|
||||
int[] sampleCompositionTimeOffsetTable = out.sampleCompositionTimeOffsetTable;
|
||||
long[] sampleDecodingTimeTable = out.sampleDecodingTimeTable;
|
||||
boolean[] sampleIsSyncFrameTable = out.sampleIsSyncFrameTable;
|
||||
|
||||
long timescale = track.timescale;
|
||||
@ -882,7 +882,7 @@ public final class FragmentedMp4Extractor implements Extractor {
|
||||
} else {
|
||||
sampleCompositionTimeOffsetTable[i] = 0;
|
||||
}
|
||||
sampleDecodingTimeTable[i] = (int) ((cumulativeTime * 1000) / timescale);
|
||||
sampleDecodingTimeTable[i] = (cumulativeTime * 1000) / timescale;
|
||||
sampleSizeTable[i] = sampleSize;
|
||||
sampleIsSyncFrameTable[i] = ((sampleFlags >> 16) & 0x1) == 0
|
||||
&& (!workaroundEveryVideoFrameIsSyncFrame || i == 0);
|
||||
|
@ -32,14 +32,14 @@ import com.google.android.exoplayer.upstream.NonBlockingInputStream;
|
||||
* The size of each sample in the run.
|
||||
*/
|
||||
public int[] sampleSizeTable;
|
||||
/**
|
||||
* The decoding time of each sample in the run.
|
||||
*/
|
||||
public int[] sampleDecodingTimeTable;
|
||||
/**
|
||||
* The composition time offset of each sample in the run.
|
||||
*/
|
||||
public int[] sampleCompositionTimeOffsetTable;
|
||||
/**
|
||||
* The decoding time of each sample in the run.
|
||||
*/
|
||||
public long[] sampleDecodingTimeTable;
|
||||
/**
|
||||
* Indicates which samples are sync frames.
|
||||
*/
|
||||
|
@ -70,12 +70,12 @@ public class PlayerControl implements MediaPlayerControl {
|
||||
|
||||
@Override
|
||||
public int getCurrentPosition() {
|
||||
return exoPlayer.getCurrentPosition();
|
||||
return (int) exoPlayer.getCurrentPosition();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDuration() {
|
||||
return exoPlayer.getDuration();
|
||||
return (int) exoPlayer.getDuration();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user