Google chrome Chromecast-页面刷新后如何重新连接到会话?

Google chrome Chromecast-页面刷新后如何重新连接到会话?,google-chrome,google-cast,Google Chrome,Google Cast,重新加载页面后,方法 cast.framework.CastContext.getInstance() 返回状态“未连接”和“无会话” 我的代码示例: const castContext = window.cast.framework.CastContext.getInstance(); castContext.setOptions({ receiverApplicationId: window.chrome.cast.media.DEFAULT_MEDIA_RECEIVER_A

重新加载页面后,方法

cast.framework.CastContext.getInstance()
返回状态“未连接”和“无会话”

我的代码示例:

const castContext = window.cast.framework.CastContext.getInstance();

castContext.setOptions({
  receiverApplicationId:
    window.chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,
  autoJoinPolicy: window.chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,
  resumeSavedSession: true
});

await castContext.requestSession(); // wait for prompt

const castSession = castContext.getCurrentSession();

const mediaInfo = new window.chrome.cast.media.MediaInfo(mediaUrl);

const request = new window.chrome.cast.media.LoadRequest(mediaInfo);

await castSession.loadMedia(request);

window.player = new window.cast.framework.RemotePlayer();

window.playerController = new window.cast.framework.RemotePlayerController(
window.player);

您能告诉我如何连接到现有会话并接收有关播放媒体的信息吗?

我四处寻找答案已经有一段时间了,您的端口切换让我思考

  • 交换端口不是有效的解决方案
  • 为什么一个解决方案突然停止工作而我的Chromecast代码没有任何改变
  • 回答:Chrome打嗝了。我猜这要么是因为几个实时刷新,要么是因为开发过程中出现了一些错误,它被缓存了

    解决方案:我清除了应用程序存储并删除了我的Chrome配置文件。重新启动Chrome后,我的解决方案与chromecast重新连接,就像以前一样


    Hm。如果在网页包设置中切换端口,会话将恢复。我把它从3000调到了8080。我一团糟:)下面的答案解决了吗?你找到(其他)解决办法了吗?