Bug 1410218 - Fix NPE when cast fails; r?sdaswani
This happened whenever starting to cast a video and loading the media failed.
MediaStatus in this case would be null and querying it would throw a
NullPointerException.
Avoiding this query when the MediaStatus is null lets the normal execution flow
continue and if loading media failed casting will fail gracefully.
MozReview-Commit-ID: 8ZOqr1FO1Dt
--- a/mobile/android/base/java/org/mozilla/gecko/ChromeCastPlayer.java
+++ b/mobile/android/base/java/org/mozilla/gecko/ChromeCastPlayer.java
@@ -81,16 +81,20 @@ class ChromeCastPlayer implements GeckoM
this.title = title;
this.callback = callback;
}
@Override
public void onStatusUpdated() {
MediaStatus mediaStatus = remoteMediaPlayer.getMediaStatus();
+ if (mediaStatus == null) {
+ return;
+ }
+
switch (mediaStatus.getPlayerState()) {
case MediaStatus.PLAYER_STATE_PLAYING:
EventDispatcher.getInstance().dispatch("MediaPlayer:Playing", null);
break;
case MediaStatus.PLAYER_STATE_PAUSED:
EventDispatcher.getInstance().dispatch("MediaPlayer:Paused", null);
break;
case MediaStatus.PLAYER_STATE_IDLE: