[英]Styling Chromecast Custom Receiver Media Player
I am using the Media Player library to cast my HLS stream and I am trying to style it. 我正在使用Media Player库来投射我的HLS流,并试图对其进行样式设置。 I want to put animations before loading etc. This what I am doing in the Media Manager's onLoad method;
我想在加载动画之前放动画。这是我在媒体管理器的onLoad方法中所做的;
window.onload = function ()
{
mediaElement = document.querySelector('video');
mediaElement.autoplay = true;
...
}
mediaManager.onLoad = function (event)
{
var title = event.data['media']['metadata']['title'];
var titleElement = this.receiverelement.querySelector('.media-title');
videoplayer.setInnerText_(titleElement, title);
var subtitle = event.data['media']['metadata']['subtitle'];
var subtitleElement = this.receiverelement.querySelector('.media-subtitle');
videoplayer.setInnerText_(subtitleElement, subtitle);
var artwork = videoplayer.getValue_(event.data, ['media', 'metadata',
'images', 0, 'url']);
var artworkElement = this.receiverelement.querySelector('.media-artwork');
videoplayer.setBackgroundImage_(artworkElement, artwork);
var autoplay = videoplayer.getValue_(event.data, ['autoplay']);
var contentId = videoplayer.getValue_(event.data, ['media', 'contentId']);
var contentType = videoplayer.getValue_(event.data, ['media', 'contentType']
);
this.videoType(contentType);
this.currentState(videoplayer.State.LOADING, false);
this.videoElement.autoplay = autoplay || true;
this.videoElement.src = contentId || '';
if (event.data['media'] && event.data['media']['contentId']) {
var url = event.data['media']['contentId'];
var mediaHost = new cast.player.api.Host({
'mediaElement': this.videoElement,
'url': url
});
mediaHost.onError = function (errorCode) {
console.error('### HOST ERROR - Fatal Error: code = ' + errorCode);
if (mediaPlayer !== null) {
mediaPlayer.unload();
}
}
var initialTimeIndexSeconds = event.data['media']['currentTime'] || 0;
var protocol = null;
var parser = document.createElement('a');
parser.href = url;
var ext = ext = parser.pathname.split('.').pop();
if (ext === 'm3u8') {
protocol = cast.player.api.CreateHlsStreamingProtocol(mediaHost);
} else if (ext === 'mpd') {
protocol = cast.player.api.CreateDashStreamingProtocol(mediaHost);
} else if (ext === 'ism/') {
protocol = cast.player.api.CreateSmoothStreamingProtocol(mediaHost);
}
console.log('### Media Protocol Identified as ' + ext);
if(protocol == null)
{
this.load.bind(this);
}
else
{
mediaPlayer = new cast.player.api.Player(mediaHost);
mediaPlayer.load(protocol, initialTimeIndexSeconds);
}
}
Here am I still using the Media Player library (which I need for DRM)? 我仍在使用Media Player库(DRM需要它)吗? videoElement variable refers to the video tag in the HTML.
videoElement变量引用HTML中的视频标签。 In the media manager onload function I set the source of that to the video url.
在媒体管理器的onload函数中,我将其源设置为视频URL。 By doing this, am I still using the Media Player library and can I still set the licenseURL for DRM etc?
这样,我是否仍在使用媒体播放器库,是否仍可以为DRM等设置licenseURL? If not, how can I style the media player?
如果没有,如何设置媒体播放器的样式?
The Styled Media Receiver also uses MPL. 样式媒体接收器也使用MPL。 If the license URL is embedded in the manifest then that should work for DRM.
如果许可证URL嵌入在清单中,则它应适用于DRM。 If you need any kind of authentication then you would need to create a custom receiver.
如果您需要任何类型的身份验证,则需要创建一个自定义接收器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.