Load the playlist into the mainSegmentLoader_ on a `mediachange` event from the …
…PlaylistLoader (#724) The PlaylistLoader signals that the active playlist has changed by triggering a mediachange event and the segmentloader needs to know about the new playlist or it will continue to select segments from the old playlist
Showing
2 changed files
with
15 additions
and
1 deletions
... | @@ -118,6 +118,10 @@ export default class MasterPlaylistController extends videojs.EventTarget { | ... | @@ -118,6 +118,10 @@ export default class MasterPlaylistController extends videojs.EventTarget { |
118 | return; | 118 | return; |
119 | } | 119 | } |
120 | 120 | ||
121 | // TODO: Create a new event on the PlaylistLoader that signals | ||
122 | // that the segments have changed in some way and use that to | ||
123 | // update the SegmentLoader instead of doing it twice here and | ||
124 | // on `mediachange` | ||
121 | this.mainSegmentLoader_.playlist(updatedPlaylist); | 125 | this.mainSegmentLoader_.playlist(updatedPlaylist); |
122 | this.mainSegmentLoader_.expired(this.masterPlaylistLoader_.expired_); | 126 | this.mainSegmentLoader_.expired(this.masterPlaylistLoader_.expired_); |
123 | this.updateDuration(); | 127 | this.updateDuration(); |
... | @@ -138,8 +142,18 @@ export default class MasterPlaylistController extends videojs.EventTarget { | ... | @@ -138,8 +142,18 @@ export default class MasterPlaylistController extends videojs.EventTarget { |
138 | }); | 142 | }); |
139 | 143 | ||
140 | this.masterPlaylistLoader_.on('mediachange', () => { | 144 | this.masterPlaylistLoader_.on('mediachange', () => { |
145 | let media = this.masterPlaylistLoader_.media(); | ||
146 | |||
141 | this.mainSegmentLoader_.abort(); | 147 | this.mainSegmentLoader_.abort(); |
148 | |||
149 | // TODO: Create a new event on the PlaylistLoader that signals | ||
150 | // that the segments have changed in some way and use that to | ||
151 | // update the SegmentLoader instead of doing it twice here and | ||
152 | // on `loadedplaylist` | ||
153 | this.mainSegmentLoader_.playlist(media); | ||
154 | this.mainSegmentLoader_.expired(this.masterPlaylistLoader_.expired_); | ||
142 | this.mainSegmentLoader_.load(); | 155 | this.mainSegmentLoader_.load(); |
156 | |||
143 | this.tech_.trigger({ | 157 | this.tech_.trigger({ |
144 | type: 'mediachange', | 158 | type: 'mediachange', |
145 | bubbles: true | 159 | bubbles: true | ... | ... |
... | @@ -409,7 +409,7 @@ QUnit.test('updates the combined segment loader on media changes', function() { | ... | @@ -409,7 +409,7 @@ QUnit.test('updates the combined segment loader on media changes', function() { |
409 | this.masterPlaylistController.mediaSource.sourceBuffers[0].trigger('updateend'); | 409 | this.masterPlaylistController.mediaSource.sourceBuffers[0].trigger('updateend'); |
410 | // media | 410 | // media |
411 | standardXHRResponse(this.requests.shift()); | 411 | standardXHRResponse(this.requests.shift()); |
412 | QUnit.equal(updates.length, 1, 'updated the segment list'); | 412 | QUnit.ok(updates.length > 0, 'updated the segment list'); |
413 | 413 | ||
414 | // verify stats | 414 | // verify stats |
415 | QUnit.equal(this.player.tech_.hls.stats.bandwidth, Infinity, 'Live stream'); | 415 | QUnit.equal(this.player.tech_.hls.stats.bandwidth, Infinity, 'Live stream'); | ... | ... |
-
Please register or sign in to post a comment