Constraint seeks within bounds for ConstantBitrateSeeker
We do this everywhere for index based seeking already. Issue: #2876 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=157568788
This commit is contained in:
parent
854c8d0381
commit
c80b60f4ac
@ -16,6 +16,7 @@
|
|||||||
package com.google.android.exoplayer2.extractor.mp3;
|
package com.google.android.exoplayer2.extractor.mp3;
|
||||||
|
|
||||||
import com.google.android.exoplayer2.C;
|
import com.google.android.exoplayer2.C;
|
||||||
|
import com.google.android.exoplayer2.util.Util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MP3 seeker that doesn't rely on metadata and seeks assuming the source has a constant bitrate.
|
* MP3 seeker that doesn't rely on metadata and seeks assuming the source has a constant bitrate.
|
||||||
@ -41,8 +42,11 @@ import com.google.android.exoplayer2.C;
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getPosition(long timeUs) {
|
public long getPosition(long timeUs) {
|
||||||
return durationUs == C.TIME_UNSET ? 0
|
if (durationUs == C.TIME_UNSET) {
|
||||||
: firstFramePosition + (timeUs * bitrate) / (C.MICROS_PER_SECOND * BITS_PER_BYTE);
|
return 0;
|
||||||
|
}
|
||||||
|
timeUs = Util.constrainValue(timeUs, 0, durationUs);
|
||||||
|
return firstFramePosition + (timeUs * bitrate) / (C.MICROS_PER_SECOND * BITS_PER_BYTE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user