Merge branch 'iFeelSmart-fix/report_time_position_when_updated'
# Conflicts: # CHANGELOG.md
This commit is contained in:
commit
803e7c8781
@ -2,7 +2,7 @@
|
||||
|
||||
### Version 6.0.0-alpha.2
|
||||
|
||||
-
|
||||
- Fix Exoplayer progress not reported when paused [#2664](https://github.com/react-native-video/react-native-video/pull/2664)
|
||||
|
||||
### Version 6.0.0-alpha.1
|
||||
|
||||
|
@ -205,18 +205,29 @@ class ReactExoplayerView extends FrameLayout implements
|
||||
private final AudioManager audioManager;
|
||||
private final AudioBecomingNoisyReceiver audioBecomingNoisyReceiver;
|
||||
|
||||
// store last progress event values to avoid sending unnecessary messages
|
||||
private long lastPos = -1;
|
||||
private long lastBufferDuration = -1;
|
||||
private long lastDuration = -1;
|
||||
|
||||
private final Handler progressHandler = new Handler(Looper.getMainLooper()) {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case SHOW_PROGRESS:
|
||||
if (player != null
|
||||
&& player.getPlaybackState() == Player.STATE_READY
|
||||
&& player.getPlayWhenReady()
|
||||
) {
|
||||
if (player != null) {
|
||||
long pos = player.getCurrentPosition();
|
||||
long bufferedDuration = player.getBufferedPercentage() * player.getDuration() / 100;
|
||||
eventEmitter.progressChanged(pos, bufferedDuration, player.getDuration(), getPositionInFirstPeriodMsForCurrentWindow(pos));
|
||||
long duration = player.getDuration();
|
||||
|
||||
if (lastPos != pos
|
||||
|| lastBufferDuration != bufferedDuration
|
||||
|| lastDuration != duration) {
|
||||
lastPos = pos;
|
||||
lastBufferDuration = bufferedDuration;
|
||||
lastDuration = duration;
|
||||
eventEmitter.progressChanged(pos, bufferedDuration, player.getDuration(), getPositionInFirstPeriodMsForCurrentWindow(pos));
|
||||
}
|
||||
msg = obtainMessage(SHOW_PROGRESS);
|
||||
sendMessageDelayed(msg, Math.round(mProgressUpdateInterval));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user