【问题标题】:Chromecast - How to reconnect to the session after page refresh?Chromecast - 页面刷新后如何重新连接到会话?
【发布时间】:2019-07-27 07:10:40
【问题描述】:

重新加载页面后,方法

cast.framework.CastContext.getInstance()

返回状态“NOT_CONNECTED”和“NO_SESSION”

我的代码示例:

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);

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

【问题讨论】:

  • 嗯。如果您在 webpack 设置中切换端口,会话将恢复。我把它从 3000 切换到 8080。我一团糟:)
  • 下面的答案解决了吗?您找到(其他)解决方案了吗?

标签: google-chrome google-cast


【解决方案1】:

我一直在寻找答案,你的端口切换让我思考。

  1. 切换端口不是一个有效的解决方案!
  2. 为什么解决方案会突然停止工作,而我的 Chromecast 代码没有任何更改?

答案:Chrome 遇到了麻烦。我猜这要么是因为几次实时刷新,要么是在开发过程中出现问题并被缓存了?!

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

【讨论】:

    猜你喜欢
    • 2019-08-05
    • 2013-12-22
    • 2019-05-16
    • 1970-01-01
    • 2014-08-16
    • 2014-07-20
    • 1970-01-01
    • 1970-01-01
    • 2017-10-03
    相关资源
    最近更新 更多