Commit 36ea0f8a by andrewlewis Committed by Oliver Woodman

Fix Seeker.getTimeUs for positions before the first frame.

Issue: #1038
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=109906628
parent f37fcddf
...@@ -47,7 +47,8 @@ import com.google.android.exoplayer.C; ...@@ -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
......
...@@ -130,7 +130,7 @@ import com.google.android.exoplayer.util.Util; ...@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment