f213f641 by David LaPalomento

Trigger duration updates indirectly so that live is correctly detected by the player

Since HLS has overridden the Flash tech's duration method, durationchange is no longer automatically fired. Whenever duration needs to be updated, trigger durationchange on the player instead of setting it directly. The player code calls back to the tech to pick up the new duration and applies styling for live playback if necessary.
1 parent d7c2b800
...@@ -227,8 +227,13 @@ var ...@@ -227,8 +227,13 @@ var
227 * Update the player duration 227 * Update the player duration
228 */ 228 */
229 updateDuration = function(playlist) { 229 updateDuration = function(playlist) {
230 // update the duration 230 var oldDuration = player.duration(),
231 player.duration(totalDuration(playlist)); 231 newDuration = totalDuration(playlist);
232
233 // if the duration has changed, invalidate the cached value
234 if (oldDuration !== newDuration) {
235 player.trigger('durationchange');
236 }
232 }; 237 };
233 238
234 /** 239 /**
......
...@@ -915,6 +915,7 @@ test('duration is Infinity for live playlists', function() { ...@@ -915,6 +915,7 @@ test('duration is Infinity for live playlists', function() {
915 standardXHRResponse(requests[0]); 915 standardXHRResponse(requests[0]);
916 916
917 strictEqual(player.duration(), Infinity, 'duration is infinity'); 917 strictEqual(player.duration(), Infinity, 'duration is infinity');
918 ok((' ' + player.el().className + ' ').indexOf(' vjs-live ') >= 0, 'added vjs-live class');
918 }); 919 });
919 920
920 test('updates the media index when a playlist reloads', function() { 921 test('updates the media index when a playlist reloads', function() {
......