Do not set player status before player object is created

This commit is contained in:
ByteHamster 2019-04-14 13:56:04 +02:00
parent 28f424e3c1
commit 0339ce7bca
2 changed files with 5 additions and 3 deletions

View File

@ -174,9 +174,9 @@ public class PlaybackServiceFlavorHelper {
} }
callback.sendNotificationBroadcast(PlaybackService.NOTIFICATION_TYPE_RELOAD, callback.sendNotificationBroadcast(PlaybackService.NOTIFICATION_TYPE_RELOAD,
PlaybackService.EXTRA_CODE_CAST); PlaybackService.EXTRA_CODE_CAST);
switchMediaPlayer(new RemotePSMP(context, callback.getMediaPlayerCallback()), RemotePSMP remotePSMP = new RemotePSMP(context, callback.getMediaPlayerCallback());
info, switchMediaPlayer(remotePSMP, info, wasLaunched);
wasLaunched); remotePSMP.init();
// hardware volume buttons control the remote device volume // hardware volume buttons control the remote device volume
mediaRouter.setMediaSessionCompat(callback.getMediaSession()); mediaRouter.setMediaSessionCompat(callback.getMediaSession());
registerWifiBroadcastReceiver(); registerWifiBroadcastReceiver();

View File

@ -62,7 +62,9 @@ public class RemotePSMP extends PlaybackServiceMediaPlayer {
startWhenPrepared = new AtomicBoolean(false); startWhenPrepared = new AtomicBoolean(false);
isBuffering = new AtomicBoolean(false); isBuffering = new AtomicBoolean(false);
remoteState = MediaStatus.PLAYER_STATE_UNKNOWN; remoteState = MediaStatus.PLAYER_STATE_UNKNOWN;
}
public void init () {
try { try {
if (castMgr.isConnected() && castMgr.isRemoteMediaLoaded()) { if (castMgr.isConnected() && castMgr.isRemoteMediaLoaded()) {
onRemoteMediaPlayerStatusUpdated(); onRemoteMediaPlayerStatusUpdated();