Fix for the player crashing and not reloading and small fixes
Sometimes the videojs player just crashes and you have to reload the stream page. Usually this only happened on the "highest (ll)" quality when pomf has hiccups, but at some point also started happening on the other qualities.
To reproduce: This code causes a player error and it crashes (sometimes the player needs to be clicked to crash):
for (let key in window.players) {
let player = window.players[key];
player.error({code: 4});
}
The console always logs an error in pomfVideoPlayerReady: VIDEOJS: ERROR: TypeError: videojs.src is not a function. I debugged the player and found the bug: videojs is the library, the src function is defined on the player and not on the library.
If you apply this patch, it works
diff --git a/default/_playerjs.tpl b/default/_playerjs.tpl
index 1b32114..9ecf4bc 100644
--- a/default/_playerjs.tpl
+++ b/default/_playerjs.tpl
@@ -152,7 +152,7 @@ window.pomfVideoPlayerReady = function(this_streamer, player_id, first){
});
this.on('error', function() {
videojs.log('Awww...dang errors?!');
- videojs.src({type: 'application/x-mpegURL', src: '//{{ memberData.server }}.pomf.tv/hls-live/' + this_streamer + '.m3u8'});
+ this.src({type: 'application/x-mpegURL', src: '//{{ memberData.server }}.pomf.tv/hls-live/' + this_streamer + '.m3u8'});
});
this.on('pause', function() {
videojs.log('paused');
But now the quality selector vanishes after an error. And changing servers now throws an error in pomfServerWidgetItem: Uncaught TypeError: player.currentSource().src is undefined.
Because an issue where the server widget caused the selector to vanish was fixed, i looked into the server widget and tried around a bit. I found you can call src with current sources which reloads the player and keeps everything else working.
Also added some small fixes that i found when working on the file.