Skip to content

Commit

Permalink
log playback errors after video play() request
Browse files Browse the repository at this point in the history
  • Loading branch information
nvedenyuk committed Oct 2, 2017
1 parent 344a753 commit ae6c306
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@hola.org/jwplayer-hlsjs",
"description": "hls.js provider for jwplayer",
"version": "0.0.76",
"version": "0.0.77",
"license": "ISC",
"homepage": "https://github.com/hola/jwplayer-hlsjs",
"scripts": {
Expand Down
21 changes: 20 additions & 1 deletion src/jwplayer.hlsjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,27 @@ function HlsProv(id){
video.dispatchEvent(new Event('seeking'));
this.hls_queued.seek = 0;
};
function check_playback_started(video){
if (video.paused)
return void hls_log('video play refused');
function rm_listeners(){
video.removeEventListener('playing', listener);
video.removeEventListener('pause', listener);
video.removeEventListener('abort', listener);
video.removeEventListener('error', listener);
}
function listener(e){
rm_listeners();
if (e.type!='playing')
hls_log('play() was interrupted by a "'+e.type+'" event');
}
video.addEventListener('playing', listener);
video.addEventListener('abort', listener);
video.addEventListener('error', listener);
video.addEventListener('pause', listener);
}
function video_play(){
var promise = video.play();
var promise = video.play()||check_playback_started(video);
if (promise && promise.catch)
{
promise.catch(function(err){
Expand Down

0 comments on commit ae6c306

Please sign in to comment.