fix the force close issue when starting casting from the video player

This commit is contained in:
Domingos Lopes 2016-04-22 22:36:57 -04:00
parent 1a33830991
commit e79a077313
2 changed files with 6 additions and 5 deletions

View File

@ -1520,7 +1520,7 @@ public class PlaybackService extends Service {
info = new PlaybackServiceMediaPlayer.PSMPInfo(PlayerStatus.STOPPED, null);
}
switchMediaPlayer(new LocalPSMP(PlaybackService.this, mediaPlayerCallback),
info, false);
info, true);
if (info.playable != null) {
sendNotificationBroadcast(NOTIFICATION_TYPE_RELOAD,
info.playable.getMediaType() == MediaType.AUDIO ? EXTRA_CODE_AUDIO : EXTRA_CODE_VIDEO);
@ -1622,8 +1622,9 @@ public class PlaybackService extends Service {
private void onCastAppConnected(boolean wasLaunched) {
Log.d(TAG, "A cast device application was " + (wasLaunched ? "launched" : "joined"));
isCasting = true;
PlaybackServiceMediaPlayer.PSMPInfo info = null;
if (mediaPlayer != null) {
PlaybackServiceMediaPlayer.PSMPInfo info = mediaPlayer.getPSMPInfo();
info = mediaPlayer.getPSMPInfo();
if (info.playerStatus == PlayerStatus.PLAYING) {
// could be pause, but this way we make sure the new player will get the correct position,
// since pause runs asynchronously and we could be directing the new player to play even before
@ -1631,11 +1632,11 @@ public class PlaybackService extends Service {
saveCurrentPosition(false, 0);
}
}
sendNotificationBroadcast(NOTIFICATION_TYPE_RELOAD, EXTRA_CODE_CAST);
switchMediaPlayer(new RemotePSMP(PlaybackService.this, mediaPlayerCallback),
(mediaPlayer != null) ? mediaPlayer.getPSMPInfo() :
(info != null) ? info :
new PlaybackServiceMediaPlayer.PSMPInfo(PlayerStatus.STOPPED, null),
wasLaunched);
sendNotificationBroadcast(NOTIFICATION_TYPE_RELOAD, EXTRA_CODE_CAST);
// hardware volume buttons control the remote device volume
mediaRouter.setMediaSessionCompat(mediaSession);
registerWifiBroadcastReceiver();

View File

@ -482,7 +482,7 @@ public class RemotePSMP extends PlaybackServiceMediaPlayer {
@Override
public void resetVideoSurface() {
throw new UnsupportedOperationException("Resetting Video Surface unsupported in Remote Media Player");
Log.e(TAG, "Resetting Video Surface unsupported in Remote Media Player");
}
@Override