我有一个帮助URL,在播放之前要使用令牌进行身份验证。如何将标记头添加到接收方CAF应用程序?我在文档中搜索但未找到任何接收器CAF应用程序的身份验证参考。
在V2播放器中,我们可以使用=>
截取请求,如下所示,但我不知道如何使用CAF应用程序。有人可以帮忙吗?
updateSegmentRequestInfo
答案 0 :(得分:2)
在播放器加载事件上设置Cookie。
使用此代码:
const context = cast.framework.CastReceiverContext.getInstance();
const playerManager = context.getPlayerManager();
const castOptions = new cast.framework.CastReceiverOptions();
let playbackConfig = (Object.assign(new cast.framework.PlaybackConfig(), playerManager.getPlaybackConfig()));
playerManager.setMessageInterceptor(
cast.framework.messages.MessageType.LOAD,
request => {
// Set cookies here.
// No need to pass cookies into header in each segment.
// console.log("content id:", request.media.contentId);
// Set your segment valid hls format : below is example:
// Refer other format:
// https://developers.google.com/cast/docs/reference/caf_receiver/cast.framework.messages#.HlsSegmentFormat
request.media.hlsSegmentFormat = cast.framework.messages.HlsSegmentFormat.TS;
return request;
});
playbackConfig.manifestRequestHandler = requestInfo => {
requestInfo.withCredentials = true;
};
playbackConfig.segmentRequestHandler = requestInfo => {
requestInfo.withCredentials = true;
};
playbackConfig.licenseRequestHandler = requestInfo => {
requestInfo.withCredentials = true;
};
castOptions.playbackConfig = playbackConfig;
context.start(castOptions);