Use the new error() method for error reporting
Trigger errors on the player using the error() method instead of firing them directly.
Showing
2 changed files
with
8 additions
and
8 deletions
... | @@ -452,8 +452,7 @@ var | ... | @@ -452,8 +452,7 @@ var |
452 | player.trigger('loadedmetadata'); | 452 | player.trigger('loadedmetadata'); |
453 | }); | 453 | }); |
454 | player.hls.playlists.on('error', function() { | 454 | player.hls.playlists.on('error', function() { |
455 | player.hls.error = player.hls.playlists.error; | 455 | player.error(player.hls.playlists.error); |
456 | player.trigger('error'); | ||
457 | }); | 456 | }); |
458 | player.hls.playlists.on('loadedplaylist', function() { | 457 | player.hls.playlists.on('loadedplaylist', function() { |
459 | var updatedPlaylist = player.hls.playlists.media(); | 458 | var updatedPlaylist = player.hls.playlists.media(); | ... | ... |
... | @@ -315,9 +315,9 @@ test('re-initializes the tech for each source', function() { | ... | @@ -315,9 +315,9 @@ test('re-initializes the tech for each source', function() { |
315 | }); | 315 | }); |
316 | 316 | ||
317 | test('triggers an error when a master playlist request errors', function() { | 317 | test('triggers an error when a master playlist request errors', function() { |
318 | var error; | 318 | var errors = 0; |
319 | player.on('error', function() { | 319 | player.on('error', function() { |
320 | error = player.hls.error; | 320 | errors++; |
321 | }); | 321 | }); |
322 | player.src({ | 322 | player.src({ |
323 | src: 'manifest/master.m3u8', | 323 | src: 'manifest/master.m3u8', |
... | @@ -328,8 +328,9 @@ test('triggers an error when a master playlist request errors', function() { | ... | @@ -328,8 +328,9 @@ test('triggers an error when a master playlist request errors', function() { |
328 | }); | 328 | }); |
329 | requests.pop().respond(500); | 329 | requests.pop().respond(500); |
330 | 330 | ||
331 | ok(error, 'an error is triggered'); | 331 | ok(player.error(), 'an error is triggered'); |
332 | strictEqual(2, error.code, 'a network error is triggered'); | 332 | strictEqual(1, errors, 'fired one error'); |
333 | strictEqual(2, player.error().code, 'a network error is triggered'); | ||
333 | }); | 334 | }); |
334 | 335 | ||
335 | test('downloads media playlists after loading the master', function() { | 336 | test('downloads media playlists after loading the master', function() { |
... | @@ -904,10 +905,10 @@ test('playlist 404 should trigger MEDIA_ERR_NETWORK', function() { | ... | @@ -904,10 +905,10 @@ test('playlist 404 should trigger MEDIA_ERR_NETWORK', function() { |
904 | equal(errorTriggered, | 905 | equal(errorTriggered, |
905 | true, | 906 | true, |
906 | 'Missing Playlist error event should trigger'); | 907 | 'Missing Playlist error event should trigger'); |
907 | equal(player.hls.error.code, | 908 | equal(player.error().code, |
908 | 2, | 909 | 2, |
909 | 'Player error code should be set to MediaError.MEDIA_ERR_NETWORK'); | 910 | 'Player error code should be set to MediaError.MEDIA_ERR_NETWORK'); |
910 | ok(player.hls.error.message, 'Player error type should inform user correctly'); | 911 | ok(player.error().message, 'included an error message'); |
911 | }); | 912 | }); |
912 | 913 | ||
913 | test('segment 404 should trigger MEDIA_ERR_NETWORK', function () { | 914 | test('segment 404 should trigger MEDIA_ERR_NETWORK', function () { | ... | ... |
-
Please register or sign in to post a comment