Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/365.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 无法连接到已设置样式的接收器_Javascript_Google Cast - Fatal编程技术网

Javascript 无法连接到已设置样式的接收器

Javascript 无法连接到已设置样式的接收器,javascript,google-cast,Javascript,Google Cast,我正在尝试构建一个简单的基于JS的web应用程序,启动一个由Google托管的样式化媒体接收器,读取您的自定义CSS文件。我已经建立了一个开发者帐户,并且已经在我的帐户中添加了应用程序。我确保在创建时选择了样式化的媒体接收器类型 我正在使用描述的基本设置来构造我的发件人。我能够让这个代码与自定义接收器一起工作。我可以在日志中看到检测到扩展名 Found cast extension: boadgeojelhgndaghljhdicfkmllpafd 我使用Cast开发者控制台上提供的应用程序I

我正在尝试构建一个简单的基于JS的web应用程序,启动一个由Google托管的样式化媒体接收器,读取您的自定义CSS文件。我已经建立了一个开发者帐户,并且已经在我的帐户中添加了应用程序。我确保在创建时选择了样式化的媒体接收器类型

我正在使用描述的基本设置来构造我的发件人。我能够让这个代码与自定义接收器一起工作。我可以在日志中看到检测到扩展名

Found cast extension: boadgeojelhgndaghljhdicfkmllpafd
我使用Cast开发者控制台上提供的应用程序ID设置会话请求

var sessionRequest = new chrome.cast.SessionRequest(id);
然后我叫:

var apiConfig = new chrome.cast.ApiConfig(this.sessionListener.bind(this),
                                          this.receiverListener.bind(this));
返回receiverListener函数不可用的值。当我尝试请求会话时,它返回错误回调,其中包含以下数据:

Object {code: "receiver_unavailable", description: null, details: null}
所以,我正试图找出我可能遗漏了什么。正如我所说,我已经使用相同的代码成功地启动了自定义接收器。以下是我正在使用的完整代码:

Polymer({
  ready: function(){
    window['__onGCastApiAvailable'] = function(loaded, errorInfo){
      if(loaded){
        this.initCast();
      }
      else{
        console.log(errorInfo);
      }
    }.bind(this);
  },
  initCast: function(){
    var id = "731AC858";
    var sessionRequest = new chrome.cast.SessionRequest(id);
    var apiConfig = new chrome.cast.ApiConfig(sessionRequest,
                                              this.sessionListener.bind(this),
                                              this.receiverListener.bind(this));
    chrome.cast.initialize(apiConfig, 
                           this.initCastSuccess.bind(this), 
                           this.initCastError.bind(this));
  },
  initCastSuccess: function(){
    this.castReady = true;
  },
  initCastError: function(e){
    console.log(e);
  },
  startCast: function(){
    chrome.cast.requestSession(this.startCastSuccess.bind(this), 
                               this.startCastError.bind(this));
  },
  startCastSuccess: function(e){
    console.log(e);
  },
  startCastError: function(e){
    console.log(e); //returns Object {code: "receiver_unavailable", description: null, details: null} when "startCast" is called.
  },
  sessionListener: function(e){
  console.log(e);
  },
  receiverListener: function(e){
    console.log(e);//returns "unavailable"
  },
});

看起来我不是不耐烦了,应用程序需要一段时间才能消化,就是托管样式媒体接收器的服务器停机了一段时间。我今天试过了,一切都很好

--更新--


我刚刚尝试创建一个全新的媒体接收器应用程序,但无法连接。所以我猜,在你开始使用之前,必须先准备一些东西。

你是在编写一个chrome/打包应用程序吗?不是,这是一个使用polymer并部署在Google app Engine上的web应用程序。此外,在本地开发服务器或部署的服务器上的结果也是相同的。