首页 > 解决方案 > 在 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 之外进行子类化的明确或干净的答案.

标签: tvmlcustom-error-handling

解决方案


推荐阅读