More workarounds for devices that crash when getting a cast context (#6378)
This commit is contained in:
parent
870fe2be56
commit
07b59d8b32
|
@ -59,11 +59,14 @@ public class CastPsmp extends PlaybackServiceMediaPlayer {
|
|||
if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context) != ConnectionResult.SUCCESS) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
if (CastContext.getSharedInstance(context).getCastState() == CastState.CONNECTED) {
|
||||
return new CastPsmp(context, callback);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public CastPsmp(@NonNull Context context, @NonNull PSMPCallback callback) {
|
||||
|
|
|
@ -16,8 +16,15 @@ public class CastStateListener implements SessionManagerListener<CastSession> {
|
|||
castContext = null;
|
||||
return;
|
||||
}
|
||||
castContext = CastContext.getSharedInstance(context);
|
||||
castContext.getSessionManager().addSessionManagerListener(this, CastSession.class);
|
||||
CastContext castCtx;
|
||||
try {
|
||||
castCtx = CastContext.getSharedInstance(context);
|
||||
castCtx.getSessionManager().addSessionManagerListener(this, CastSession.class);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
castCtx = null;
|
||||
}
|
||||
castContext = castCtx;
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
|
|
Loading…
Reference in New Issue