chore(exoplayer): ensure no NPE happen
This commit is contained in:
parent
48870e38e1
commit
e33e2a9cb5
@ -215,20 +215,22 @@ class ReactExoplayerView extends FrameLayout implements
|
|||||||
public void handleMessage(Message msg) {
|
public void handleMessage(Message msg) {
|
||||||
switch (msg.what) {
|
switch (msg.what) {
|
||||||
case SHOW_PROGRESS:
|
case SHOW_PROGRESS:
|
||||||
long pos = player.getCurrentPosition();
|
if (player != null) {
|
||||||
long bufferedDuration = player.getBufferedPercentage() * player.getDuration() / 100;
|
long pos = player.getCurrentPosition();
|
||||||
long duration = player.getDuration();
|
long bufferedDuration = player.getBufferedPercentage() * player.getDuration() / 100;
|
||||||
|
long duration = player.getDuration();
|
||||||
|
|
||||||
if (lastPos != pos
|
if (lastPos != pos
|
||||||
|| lastBufferDuration != bufferedDuration
|
|| lastBufferDuration != bufferedDuration
|
||||||
|| lastDuration != duration) {
|
|| lastDuration != duration) {
|
||||||
lastPos = pos;
|
lastPos = pos;
|
||||||
lastBufferDuration = bufferedDuration;
|
lastBufferDuration = bufferedDuration;
|
||||||
lastDuration = duration;
|
lastDuration = duration;
|
||||||
eventEmitter.progressChanged(pos, bufferedDuration, player.getDuration(), getPositionInFirstPeriodMsForCurrentWindow(pos));
|
eventEmitter.progressChanged(pos, bufferedDuration, player.getDuration(), getPositionInFirstPeriodMsForCurrentWindow(pos));
|
||||||
|
}
|
||||||
|
msg = obtainMessage(SHOW_PROGRESS);
|
||||||
|
sendMessageDelayed(msg, Math.round(mProgressUpdateInterval));
|
||||||
}
|
}
|
||||||
msg = obtainMessage(SHOW_PROGRESS);
|
|
||||||
sendMessageDelayed(msg, Math.round(mProgressUpdateInterval));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user