我们基于cast.framework.events.EventType.ERROR事件创建了一个带有通用错误侦听器的自定义CAF接收器:
playerManager.addEventListener(cast.framework.events.EventType.ERROR, event => {
if (playerManager.getPlayerState() != "IDLE") {
let errorCode = (event.detailedErrorCode != undefined ?event.detailedErrorCode : null);
let errorMessage = null;
if ((event.error != undefined) && (event.error.reason != null)) errorMessage = event.error.reason;
playerManager.setIdleReason(cast.framework.messages.IdleReason.ERROR);
customErrorCodeClass.display(errorCode, errorMessage);
});
此处理程序正常工作,但有时播放器会针对单个片段引发“404片段错误”,从而导致视频停止。我们无法知道该错误是否与该特定片段有关,或者是否会有其他404片段,因此我们无法从错误处理程序中排除该错误。
有人知道解决此问题的更好方法吗?
答案 0 :(得分:0)
添加以下日志,以便您了解碎片发生的情况
debug
不要忘记将cast.framework.CastReceiverContext.getInstance().setLoggerLevel(cast.framework.LoggerLevel.DEBUG);
设置为记录器级别
var ss = SpreadsheetApp.getActiveSpreadsheet();
var chosenId;
var templates = {
"templateId_PL_1" : "1oS_11gz_123456789abcdefghijklmnop",
"templateId_PL_2" : "11gasdsz_123456789abcdefghijklmnop",
"templateId_PL_3" : "1JMo11gz_123456789abcdefghijklmnop",
"templateId_EN_1" : "1KTx11gz_123456789abcdefghijklmnop",
"templateId_EN_2" : "1_VQBgsz_123456789abcdefghijklmnop",
}
// reaction to form submit event
function onFormSubmit(e) {
//check source of data by getting sheet name, i.e. "PL_1" or "EN_2"
var range = e.range;
chosenId = range.getSheet().getName();
//get corresponding named range in "master" worksheet
var trainingData = ss.getRangeByName(chosenId).getValues();
//create new user object
var userData = {
//get submitted data from post
"Title":[e.values[1]],
"Name":[e.values[2]],
"Surname":[e.values[3]],
"Email":[e.values[4]],
//get data from named range
"Client":[trainingData[1][0]],
"Training":[trainingData[1][3]],
"Date":[trainingData[1][1]],
};
//generate certs
createAndUpdateCertificate(userData);
}
function createAndUpdateCertificate(userObj){
//create template copy according to data source
var tempId = "templateId_"+chosenId;
var copy = DriveApp.getFileById(templates[tempId]).makeCopy("temp");
var presentationID = copy.getId();
//open copied presentation and go to 1st (only) slide
var presentation = SlidesApp.openById(presentationID);
var firstSlide = presentation.getSlides()[0]
//replace texts in the slide
firstSlide.replaceAllText("<<Title>>", userObj.Title);
firstSlide.replaceAllText("<<Name>>", userObj.Name);
firstSlide.replaceAllText("<<Surname>>", userObj.Surname);
firstSlide.replaceAllText("<<Training>>", userObj.Training);
firstSlide.replaceAllText("<<Date>>", userObj.Date);
//close the copy
presentation.saveAndClose();
//sending certs
sendCerts(
presentationID,
userObj.Email,
userObj.Name,
userObj.Surname,
userObj.Training,
userObj.Date
);
//delete copy
copy.setTrashed(true);
}
function sendCerts(cert, email, name, surname, training, date){
//fetch cert as pdf
var docblob = DriveApp.getFileById(cert).getAs('application/pdf');
docblob.setName(date+"-"+"CERT "+training+"-"+name+" "+surname+".pdf");
//save the pdf in appropriate folder as a backup
var dest = DriveApp.getFolderById("1K2k-123456789abcdefghijklmnop")
var file = dest.createFile(docblob);
MailApp.sendEmail(
email,
"test", // title
"test", // body
{ noReply: true,
attachments: [file]
}
);
}