我正在开发一个 CAF 网络接收器,但是当 setMessageInterceptor 中针对“LOAD”类型引发错误时,我无法在 Nest HUB 上听到 Google Assistant 语音,而它适用于“SEEK”类型。
这是 SEEK 的代码:
playerManager.setMessageInterceptor(
cast.framework.messages.MessageType.SEEK, seekData => {
let e = new cast.framework.messages.ErrorData(cast.framework.messages.ErrorType
.LOAD_CANCELLED);
e.reason = cast.framework.messages.ErrorReason.PARENTAL_CONTROL_RESTRICTED;
return e;
});
这对于负载:
playerManager.setMessageInterceptor(
cast.framework.messages.MessageType.LOAD, loadRequestData => {
let e = new cast.framework.messages.ErrorData(cast.framework.messages.ErrorType
.LOAD_CANCELLED);
e.reason = cast.framework.messages.ErrorReason.PARENTAL_CONTROL_RESTRICTED;
return e;
});
显然,真正的“加载”案例更复杂,但如果我在这里使用谷歌代码(https://developers.google.com/cast/docs/web_receiver/core_features#error_handling)我听不到任何声音。我正在为实体流使用 CaC 工具https://casttool.appspot.com/cactool/index.html。
playerManager.setMessageInterceptor(
cast.framework.messages.MessageType.LOAD, loadRequestData => {
const error = new cast.framework.messages.ErrorData(cast.framework.messages.ErrorType.LOAD_CANCELLED);
loadRequestData.media = null; // trying to force error
if (!loadRequestData || !loadRequestData.media) {
error.reason = cast.framework.messages.ErrorReason.INVALID_PARAM;
return error;
}
...
return loadRequestData;
});