Constraint buffered percentage to [0,100]

Issue: #2902

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=158142754
This commit is contained in:
olly 2017-06-06 08:21:38 -07:00 committed by Oliver Woodman
parent 643083194d
commit 1ac8420b7f

View File

@ -305,10 +305,10 @@ import java.util.concurrent.CopyOnWriteArraySet;
if (timeline.isEmpty()) { if (timeline.isEmpty()) {
return 0; return 0;
} }
long bufferedPosition = getBufferedPosition(); long position = getBufferedPosition();
long duration = getDuration(); long duration = getDuration();
return (bufferedPosition == C.TIME_UNSET || duration == C.TIME_UNSET) ? 0 return position == C.TIME_UNSET || duration == C.TIME_UNSET ? 0
: (int) (duration == 0 ? 100 : (bufferedPosition * 100) / duration); : (duration == 0 ? 100 : Util.constrainValue((int) ((position * 100) / duration), 0, 100));
} }
@Override @Override