Fixed crash when exiting app during playback.
This commit is contained in:
parent
bb2d385460
commit
d2a8aeeb34
2 changed files with 7 additions and 1 deletions
|
@ -463,6 +463,10 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements
|
|||
* Receives information from MediaRouterPlayService about playback status.
|
||||
*/
|
||||
public void receivePlaybackStatus(MediaItemStatus status) {
|
||||
// Views may not exist if fragment was just created/destroyed.
|
||||
if (getView() == null)
|
||||
return;
|
||||
|
||||
int currentTime = (int) status.getContentPosition() / 1000;
|
||||
int totalTime = (int) status.getContentDuration() / 1000;
|
||||
|
||||
|
|
|
@ -315,7 +315,9 @@ public class MediaRouterPlayService extends Service {
|
|||
@Override
|
||||
public void onResult(Bundle data) {
|
||||
MediaItemStatus status = MediaItemStatus.fromBundle(data);
|
||||
|
||||
if (status == null)
|
||||
return;
|
||||
|
||||
if (mRouterFragment.get() != null)
|
||||
mRouterFragment.get().receivePlaybackStatus(status);
|
||||
if (status.getPlaybackState() != MediaItemStatus.PLAYBACK_STATE_PENDING &&
|
||||
|
|
Reference in a new issue