DRM WideVine 视频无法从 android cast sender 应用程序播放
DRM WideVine video not playing from android cast sender application
我正在使用以下 cast 接收器
当我将 android 发送器连接到 chromecast 设备时,它显示黑屏并且从不播放视频。
https://github.com/googlecast/CastReferencePlayer
我在接收器中为 widevine 设置 licenseUrl 如下:
sampleplayer.CastPlayer.prototype.preloadVideo_ = function(mediaInformation) {
this.log_('preloadVideo_');
var self = this;
var url = mediaInformation.contentId;
var protocolFunc = sampleplayer.getProtocolFunction_(mediaInformation);
if (!protocolFunc) {
this.log_('No protocol found for preload');
return false;
}
var host = new cast.player.api.Host({
'url': url,
'mediaElement': self.mediaElement_
});
host.onError = function() {
self.preloadPlayer_.unload();
self.preloadPlayer_ = null;
self.showPreviewModeMetadata(false);
self.displayPreviewMode_ = false;
self.log_('Error during preload');
};
host.licenseUrl = event.data.customData.licenseUrl;
self.preloadPlayer_ = new cast.player.api.Player(host);
self.preloadPlayer_.preload(protocolFunc(host));
return true;
};
host.licenseUrl = event.data.customData.licenseUrl;
我将它托管在一个在开发者控制台上注册的 https 服务器上。
我在 json 对象中将自定义数据作为 licenseUrl 传递。
我的 android 发件人设置 媒体信息 的代码如下。
private MediaInfo buildMediaInfo() {
MediaMetadata movieMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE);
movieMetadata.putString(MediaMetadata.KEY_SUBTITLE, "Subtitle");
movieMetadata.putString(MediaMetadata.KEY_TITLE, "Title");
jsonObj = new JSONObject();
try{
jsonObj.put("licenseUrl","https://wv.test.expressplay.com/hms/wv/rights/?ExpressPlayToken=token-value");
}catch (JSONException e){
Log.e(null,"Failed to add description to the json object", e);
}
/*drmModel.getData().getStreamURL()*/
return new MediaInfo.Builder("https://pathOfMystream.mpd")
.setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
.setContentType("application/dash+xml")
.setMetadata(movieMetadata)
.setCustomData(jsonObj)
.setStreamDuration(player.getDuration()*1000)
.build();
}
还需要进行哪些更改?
我需要编辑接收器吗?如果是,那么需要进行哪些编辑?
是customData中的字符串名称"licenseUrl"需要
改变了吗?
- 在托管视频内容的 S3 服务器上启用了 CORS。
请帮忙!我被困在这里一个多星期了。
谢谢。
我发现从 android 发件人应用程序连接时 event.data.customData
未定义。
所以我用了event.data.media.customData
并访问 key 如下:
if(event.data.media.customData['licenseUrl'] !== null){
console.log('setting license URL from mobile');
host.licenseUrl = event.data.media.customData.licenseUrl;
}
我正在使用以下 cast 接收器
当我将 android 发送器连接到 chromecast 设备时,它显示黑屏并且从不播放视频。
https://github.com/googlecast/CastReferencePlayer
我在接收器中为 widevine 设置 licenseUrl 如下:
sampleplayer.CastPlayer.prototype.preloadVideo_ = function(mediaInformation) {
this.log_('preloadVideo_');
var self = this;
var url = mediaInformation.contentId;
var protocolFunc = sampleplayer.getProtocolFunction_(mediaInformation);
if (!protocolFunc) {
this.log_('No protocol found for preload');
return false;
}
var host = new cast.player.api.Host({
'url': url,
'mediaElement': self.mediaElement_
});
host.onError = function() {
self.preloadPlayer_.unload();
self.preloadPlayer_ = null;
self.showPreviewModeMetadata(false);
self.displayPreviewMode_ = false;
self.log_('Error during preload');
};
host.licenseUrl = event.data.customData.licenseUrl;
self.preloadPlayer_ = new cast.player.api.Player(host);
self.preloadPlayer_.preload(protocolFunc(host));
return true;
};
host.licenseUrl = event.data.customData.licenseUrl;
我将它托管在一个在开发者控制台上注册的 https 服务器上。
我在 json 对象中将自定义数据作为 licenseUrl 传递。
我的 android 发件人设置 媒体信息 的代码如下。
private MediaInfo buildMediaInfo() {
MediaMetadata movieMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE);
movieMetadata.putString(MediaMetadata.KEY_SUBTITLE, "Subtitle");
movieMetadata.putString(MediaMetadata.KEY_TITLE, "Title");
jsonObj = new JSONObject();
try{
jsonObj.put("licenseUrl","https://wv.test.expressplay.com/hms/wv/rights/?ExpressPlayToken=token-value");
}catch (JSONException e){
Log.e(null,"Failed to add description to the json object", e);
}
/*drmModel.getData().getStreamURL()*/
return new MediaInfo.Builder("https://pathOfMystream.mpd")
.setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
.setContentType("application/dash+xml")
.setMetadata(movieMetadata)
.setCustomData(jsonObj)
.setStreamDuration(player.getDuration()*1000)
.build();
}
还需要进行哪些更改?
我需要编辑接收器吗?如果是,那么需要进行哪些编辑?
是customData中的字符串名称"licenseUrl"需要
改变了吗?- 在托管视频内容的 S3 服务器上启用了 CORS。
请帮忙!我被困在这里一个多星期了。
谢谢。
我发现从 android 发件人应用程序连接时 event.data.customData
未定义。
所以我用了event.data.media.customData
并访问 key 如下:
if(event.data.media.customData['licenseUrl'] !== null){
console.log('setting license URL from mobile');
host.licenseUrl = event.data.media.customData.licenseUrl;
}