How to catch Video stream url error and redirect to a different url? Basic tvOS tvml app
New to TVML, any help is appreciated and thanks in advance.
Have tried adding try/catch block inside js file, but can not get to work. Also since this is an issue with server response the evaluatescripts option is not available, since the script is valid just not the return from the server.
There appears to be a solution that attaches a listener on the tvmlkit class outside of the javascript. https://qiita.com/hiroakit/items/8a91377867db18590d2c#introduction it definitely does not integrate well into the 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();
}
But...seems that there should be a simple way to detect a 400, 401, 500, etc error and redirect to a different url without exiting js, but not finding any clear or clean answers that don't require subclassing outside of js.