Chromecast Receiver App - Unexpected command, player is in IDLE state

谁都会走 提交于 2019-12-02 08:59:08

I hope this can help someone.

I could successfully load and start a video with the PlayerManger using playerManager.load(loadRequestData) and playerManager.play(). However, once I stopped using playerManager.stop() and then tried to play again, I used to get this error:

[cast.receiver.MediaManager] Unexpected command, player is in IDLE state so the media session ID is not valid yet

This happens because the playerManager.stop() method unloads the video from the tag.

To fix this behaviour, just check if a video is loaded before playing.

Example:

if (isNaN(playerManager.getDurationSec())) {
    // the player has been stopped, then I reload the video
    // Load with autoplay: playerManager.load(loadRequestData);
}
else {
    playerManager.play();
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!