2016-05-17 73 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中的'#'字符。它是一個參考符號。如果我使用任何其他符號,它工作正常。 ---------如果你能讓我知道如何修正添加標題-----真的很感激。 –