tvml - 在 tvOS TVML 中处理/捕获视频流错误和重定向的方法
问题描述
如何捕获视频流 url 错误并重定向到不同的 url?基本的 tvOS tvml 应用程序
TVML 新手,任何帮助表示赞赏并提前致谢。
已尝试在 js 文件中添加 try/catch 块,但无法开始工作。此外,由于这是服务器响应的问题,因此 evaluatescripts 选项不可用,因为脚本有效,但不是来自服务器的返回。
似乎有一个解决方案可以在 javascript 之外的 tvmlkit 类上附加一个侦听器。 https://qiita.com/hiroakit/items/8a91377867db18590d2c#introduction 它肯定不能很好地集成到 js 中。
App.onLaunch = function(options) {
//MARK: - Launch HLS
streaming("G******V", "http://dcun****/master.m3u8");
};
function streaming(title, url){
// 1: player handles networking, decoding, user interface and interaction.
var player = new Player();
// 2: Please update for music streaming with 'audio' key.
var video = new MediaItem('video', url);
video.title = title;
// 3: player requires a list of media items
player.playlist = new Playlist();
player.playlist.push(video);
// 4: run.
player.play();
}
但是...似乎应该有一种简单的方法来检测 400、401、500 等错误并在不退出 js 的情况下重定向到不同的 url,但没有找到任何不需要在 js 之外进行子类化的明确或干净的答案.
解决方案
推荐阅读
- python - 'ValueError: Image with id {} already added' 在 OpenImage 数据集上运行评估时
- php - 我是否应该使用不同的表为我的迁移制作多个模型
- r - R数据表中的滞后财务数据
- django - 如何在 CreateView 中发送 cookie?
- firebase - 即使在错误的债权人颤动火力基地后也能登录
- angular - 需要帮助以角度添加组件
- c++ - 尝试初始化动态数组时出现异常未处理
- python - 对 CSV 应用一个简单的函数并保存多个 csv 文件
- java - 使用带有 set 和 get 方法的布尔值
- java - 是否可以反转列表视图中的顺序?