Fix Seeker.getTimeUs for positions before the first frame.

Issue: #1038
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=109906628
This commit is contained in:
andrewlewis 2015-12-10 09:33:48 -08:00 committed by Oliver Woodman
parent 99b34a1287
commit 38148b303f
2 changed files with 3 additions and 2 deletions

View file

@ -47,7 +47,8 @@ import com.google.android.exoplayer.C;
@Override @Override
public long getTimeUs(long position) { public long getTimeUs(long position) {
return ((position - firstFramePosition) * C.MICROS_PER_SECOND * BITS_PER_BYTE) / bitrate; return (Math.max(0, position - firstFramePosition) * C.MICROS_PER_SECOND * BITS_PER_BYTE)
/ bitrate;
} }
@Override @Override

View file

@ -130,7 +130,7 @@ import com.google.android.exoplayer.util.Util;
@Override @Override
public long getTimeUs(long position) { public long getTimeUs(long position) {
if (!isSeekable()) { if (!isSeekable() || position < firstFramePosition) {
return 0L; return 0L;
} }
double offsetByte = 256.0 * (position - firstFramePosition) / sizeBytes; double offsetByte = 256.0 * (position - firstFramePosition) / sizeBytes;