6dabe4c1 by Gary Katsevman

Request a new playlist based on initial playlist

1 parent d55d72d5
...@@ -104,11 +104,31 @@ videojs.Hls.prototype.handleSourceOpen = function() { ...@@ -104,11 +104,31 @@ videojs.Hls.prototype.handleSourceOpen = function() {
104 this.playlists = new videojs.Hls.PlaylistLoader(this.src_, settings.withCredentials); 104 this.playlists = new videojs.Hls.PlaylistLoader(this.src_, settings.withCredentials);
105 105
106 this.playlists.on('loadedmetadata', videojs.bind(this, function() { 106 this.playlists.on('loadedmetadata', videojs.bind(this, function() {
107 var selectedPlaylist, loaderHandler;
108
107 oldMediaPlaylist = this.playlists.media(); 109 oldMediaPlaylist = this.playlists.media();
108 110
109 // periodically check if new data needs to be downloaded or 111 // periodically check if new data needs to be downloaded or
110 // buffered data should be appended to the source buffer 112 // buffered data should be appended to the source buffer
113
114 if (this.bandwidth !== this.playlists.bandwidth) {
115 this.bandwidth = this.playlists.bandwidth;
116
117 selectedPlaylist = this.selectPlaylist();
118 if (selectedPlaylist === oldMediaPlaylist) {
111 this.fillBuffer(); 119 this.fillBuffer();
120 } else {
121 this.playlists.media(selectedPlaylist);
122 loaderHandler = videojs.bind(this, function() {
123 this.fillBuffer();
124 this.playlists.off('loadedplaylist', loaderHandler);
125 });
126 this.playlists.on('loadedplaylist', loaderHandler);
127 }
128 } else {
129 this.fillBuffer();
130 }
131
112 player.on('timeupdate', videojs.bind(this, this.fillBuffer)); 132 player.on('timeupdate', videojs.bind(this, this.fillBuffer));
113 player.on('timeupdate', videojs.bind(this, this.drainBuffer)); 133 player.on('timeupdate', videojs.bind(this, this.drainBuffer));
114 player.on('waiting', videojs.bind(this, this.drainBuffer)); 134 player.on('waiting', videojs.bind(this, this.drainBuffer));
......