2016-05-17 75 views
0

您好我想实现的任何一个低于Host.updateLicenseRequestInfo无法添加页眉

1)设置额外的令牌由代码“许可URL requestInfo.url = requestInfo.url +“# 12345678" ;”

OR

2)设置标头由代码 'requestInfo.headers =新的字符串(' 令牌:12345678 \ r \ n ');'

但似乎没有工作。

在更新接收者日志中的url之后,我在许可证url的末尾看到'更新的requestInfo.url'和额外的'#12345678'。但是,在许可证服务器上,我只能得到未经修改的网址(无#12345678)。

与requestInfo.headers一样。当请求进入许可证服务器时,我没有看到我在接收器应用程序中设置的任何标题。

我也试过返回requestInfo;但与此铬合播不能玩任何东西。所以我评论了退货声明。

希望任何指针来解决这个问题。这是我的代码。

var host = new cast.player.api.Host({ 
    'url': url, 
    'mediaElement': this.mediaElement_ 
    }); 

    host.onManifestReady = function() { 
    self.log_('prototype.loadVideo_::My onManifestReady'); 
    }; 


host.updateLicenseRequestInfo = function(requestInfo){ 
     self.log_('prototype.loadVideo_::updateLicenseRequestInfo()'); 
     self.log_('requestInfo.url ' + requestInfo.url); 
     self.log_('requestInfo.headers ' + requestInfo.headers); 
     self.log_('requestInfo.protectionSystem ' + requestInfo.protectionSystem); 
     self.log_('requestInfo.setResponse ' + requestInfo.setResponse); 
     self.log_('requestInfo.skipRequest ' + requestInfo.skipRequest); 
     self.log_('requestInfo.timeoutInterval ' + requestInfo.timeoutInterval); 
     self.log_('requestInfo.withCredentials ' + requestInfo.withCredentials); 
     requestInfo.url = requestInfo.url + "#12345678"; 
     //host.licenseUrl = requestInfo.url; 
     //requestInfo.headers = new String('token:12345678\r\n'); 
     self.log_('Updated requestInfo.url ' + requestInfo.url); 
     self.log_('Updated requestInfo.headers ' + requestInfo.headers); 
     //return requestInfo; 
}; 

this.player_ = new cast.player.api.Player(host); 

回答

0

updateLicenseRequestInfo - 使主机定制用于从服务器获取媒体许可请求的信息。应用程序应该重写此方法以将标记添加到url,设置标题或withCredentials标志。

以下是关于如何使用它的示例代码。

host.updateManifestRequestInfo = function(requestInfo) { 
    if (!requestInfo.url) { 
    requestInfo.url = this.url; 
    } 
    requestInfo.withCredentials = true; 
}; 

host.updateLicenseRequestInfo = function(requestInfo) { 
    requestInfo.withCredentials = true; 
}; 

host.updateSegmentRequestInfo = function(requestInfo) { 
    requestInfo.withCredentials = true; 
}; 

您还可以访问此page欲了解更多信息。

+0

嗨KENdi谢谢你的回复。你是否看到我的代码中设置标头“//requestInfo.headers = new String('token:12345678 \ r \ n');”的错误。通过添加的标题,Chromecast只是挂起。 1)我能够解决在URL中添加令牌的问题。问题在于URL中的'#'字符。它是一个参考符号。如果我使用任何其他符号,它工作正常。 ---------如果你能让我知道如何修正添加标题-----真的很感激。 –