Chromecast Android Sender RemoteMediaPlayer producing No current media session

前端 未结 2 584
礼貌的吻别
礼貌的吻别 2021-01-28 15:26

I have been able to successfully cast video to a Chromecast and have the option let the video play when disconnecting and it all works great. However, if I choose to quit the ap

2条回答
  •  花落未央
    2021-01-28 15:52

    The media session ID is part of the internal state of the RemoteMediaPlayer object. Whenever the receiver state changes, it sends updated state information to the sender, which then causes the internal state of the RemoteMediaPlayer object to get updated.

    If you disconnect from the application, then this state inside the RemoteMediaPlayer will be cleared.

    When you re-establish the connection to the (still running) receiver application, you need to call RemoteMediaPlayer.requestStatus() and wait for the OnStatusUpdatedListener.onStatusUpdated() callback. This will fetch the current media status (including the current session ID) from the receiver and update the internal state of the RemoteMediaPlayer object accordingly. Once this is done, if RemoteMediaPlayer.getMediaStatus() returns non-null, then it means that there is an active media session that you can control.

提交回复
热议问题