Bug 1055764 - "crash in java.lang.IllegalStateException: No current media session at com.google.android.gms.internal.gp.dV(Unknown Source)" [r=mark.finkle]

This commit is contained in:
wesj 2014-10-02 11:15:00 -07:00
Родитель 1a81c9a195
Коммит b0c15a77f0
1 изменённых файлов: 58 добавлений и 43 удалений

Просмотреть файл

@ -253,18 +253,23 @@ class ChromeCast implements GeckoMediaPlayer {
return;
}
remoteMediaPlayer.play(apiClient).setResultCallback(new ResultCallback<MediaChannelResult>() {
@Override
public void onResult(MediaChannelResult result) {
Status status = result.getStatus();
if (!status.isSuccess()) {
debug("Unable to play: " + status.getStatusCode());
callback.sendError(status.toString());
} else {
callback.sendSuccess(null);
try {
remoteMediaPlayer.play(apiClient).setResultCallback(new ResultCallback<MediaChannelResult>() {
@Override
public void onResult(MediaChannelResult result) {
Status status = result.getStatus();
if (!status.isSuccess()) {
debug("Unable to play: " + status.getStatusCode());
callback.sendError(status.toString());
} else {
callback.sendSuccess(null);
}
}
}
});
});
} catch(IllegalStateException ex) {
// The media player may throw if the session has been killed. For now, we're just catching this here.
callback.sendError("Error playing");
}
}
public void pause(final EventCallback callback) {
@ -272,18 +277,23 @@ class ChromeCast implements GeckoMediaPlayer {
return;
}
remoteMediaPlayer.pause(apiClient).setResultCallback(new ResultCallback<MediaChannelResult>() {
@Override
public void onResult(MediaChannelResult result) {
Status status = result.getStatus();
if (!status.isSuccess()) {
debug("Unable to pause: " + status.getStatusCode());
callback.sendError(status.toString());
} else {
callback.sendSuccess(null);
try {
remoteMediaPlayer.pause(apiClient).setResultCallback(new ResultCallback<MediaChannelResult>() {
@Override
public void onResult(MediaChannelResult result) {
Status status = result.getStatus();
if (!status.isSuccess()) {
debug("Unable to pause: " + status.getStatusCode());
callback.sendError(status.toString());
} else {
callback.sendSuccess(null);
}
}
}
});
});
} catch(IllegalStateException ex) {
// The media player may throw if the session has been killed. For now, we're just catching this here.
callback.sendError("Error pausing");
}
}
public void end(final EventCallback callback) {
@ -291,32 +301,37 @@ class ChromeCast implements GeckoMediaPlayer {
return;
}
Cast.CastApi.stopApplication(apiClient).setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(Status result) {
if (result.isSuccess()) {
try {
Cast.CastApi.removeMessageReceivedCallbacks(apiClient, remoteMediaPlayer.getNamespace());
remoteMediaPlayer = null;
mSessionId = null;
apiClient.disconnect();
apiClient = null;
try {
Cast.CastApi.stopApplication(apiClient).setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(Status result) {
if (result.isSuccess()) {
try {
Cast.CastApi.removeMessageReceivedCallbacks(apiClient, remoteMediaPlayer.getNamespace());
remoteMediaPlayer = null;
mSessionId = null;
apiClient.disconnect();
apiClient = null;
if (callback != null) {
callback.sendSuccess(null);
if (callback != null) {
callback.sendSuccess(null);
}
return;
} catch(Exception ex) {
debug("Error ending", ex);
}
}
return;
} catch(Exception ex) {
debug("Error ending", ex);
if (callback != null) {
callback.sendError(result.getStatus().toString());
}
}
if (callback != null) {
callback.sendError(result.getStatus().toString());
}
}
});
});
} catch(IllegalStateException ex) {
// The media player may throw if the session has been killed. For now, we're just catching this here.
callback.sendError("Error stopping");
}
}
class MirrorChannel implements MessageReceivedCallback {