a369f3a0 by Jon-Carlos Rivera

Merge pull request #367 from videojs/add-loadstart-5

Add loadstart 5
2 parents c3592df3 096757e7
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
30 "grunt-github-releaser": "^0.1.17", 30 "grunt-github-releaser": "^0.1.17",
31 "grunt-karma": "~0.6.2", 31 "grunt-karma": "~0.6.2",
32 "grunt-open": "0.2.3", 32 "grunt-open": "0.2.3",
33 "grunt-protractor-runner": "git+https://github.com/forbesjo/grunt-protractor-runner.git#webdriverManagerUpdate", 33 "grunt-protractor-runner": "forbesjo/grunt-protractor-runner.git#webdriverManagerUpdate",
34 "grunt-shell": "0.6.1", 34 "grunt-shell": "0.6.1",
35 "grunt-version": "^1.0.0", 35 "grunt-version": "^1.0.0",
36 "karma": "~0.10.0", 36 "karma": "~0.10.0",
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
48 }, 48 },
49 "dependencies": { 49 "dependencies": {
50 "pkcs7": "^0.2.2", 50 "pkcs7": "^0.2.2",
51 "videojs-contrib-media-sources": "git+ssh://git@github.com:videojs/videojs-contrib-media-sources.git#mse-mp2t-polyfill", 51 "videojs-contrib-media-sources": "videojs/videojs-contrib-media-sources.git#mse-mp2t-polyfill",
52 "videojs-swf": "5.0.0-rc0" 52 "videojs-swf": "5.0.0-rc0"
53 } 53 }
54 } 54 }
......
...@@ -131,6 +131,12 @@ videojs.Hls.prototype.src = function(src) { ...@@ -131,6 +131,12 @@ videojs.Hls.prototype.src = function(src) {
131 // load the MediaSource into the player 131 // load the MediaSource into the player
132 this.mediaSource.addEventListener('sourceopen', this.handleSourceOpen.bind(this)); 132 this.mediaSource.addEventListener('sourceopen', this.handleSourceOpen.bind(this));
133 133
134 // We need to trigger this asynchronously to give others the chance
135 // to bind to the event when a source is set at player creation
136 setTimeout(function() {
137 this.tech_.trigger('loadstart');
138 }.bind(this), 1);
139
134 // The index of the next segment to be downloaded in the current 140 // The index of the next segment to be downloaded in the current
135 // media playlist. When the current media playlist is live with 141 // media playlist. When the current media playlist is live with
136 // expiring segments, it may be a different value from the media 142 // expiring segments, it may be a different value from the media
...@@ -210,6 +216,14 @@ videojs.Hls.prototype.src = function(src) { ...@@ -210,6 +216,14 @@ videojs.Hls.prototype.src = function(src) {
210 }.bind(this)); 216 }.bind(this));
211 217
212 this.playlists.on('error', function() { 218 this.playlists.on('error', function() {
219 // close the media source with the appropriate error type
220 if (this.playlists.error.code === 2) {
221 this.mediaSource.endOfStream('network');
222 } else if (this.playlists.error.code === 4) {
223 this.mediaSource.endOfStream('decode');
224 }
225
226 // if this error is unrecognized, pass it along to the tech
213 this.tech_.error(this.playlists.error); 227 this.tech_.error(this.playlists.error);
214 }.bind(this)); 228 }.bind(this));
215 229
...@@ -425,7 +439,7 @@ videojs.Hls.prototype.play = function() { ...@@ -425,7 +439,7 @@ videojs.Hls.prototype.play = function() {
425 439
426 // if the viewer has paused and we fell out of the live window, 440 // if the viewer has paused and we fell out of the live window,
427 // seek forward to the earliest available position 441 // seek forward to the earliest available position
428 if (this.tech_.duration() === Infinity) { 442 if (this.duration() === Infinity) {
429 if (this.tech_.currentTime() < this.tech_.seekable().start(0)) { 443 if (this.tech_.currentTime() < this.tech_.seekable().start(0)) {
430 this.tech_.setCurrentTime(this.tech_.seekable().start(0)); 444 this.tech_.setCurrentTime(this.tech_.seekable().start(0));
431 } 445 }
...@@ -903,11 +917,7 @@ videojs.Hls.prototype.drainBuffer = function(event) { ...@@ -903,11 +917,7 @@ videojs.Hls.prototype.drainBuffer = function(event) {
903 return; 917 return;
904 } 918 }
905 919
906
907
908
909 segmentInfo = segmentBuffer[0]; 920 segmentInfo = segmentBuffer[0];
910
911 mediaIndex = segmentInfo.mediaIndex; 921 mediaIndex = segmentInfo.mediaIndex;
912 playlist = segmentInfo.playlist; 922 playlist = segmentInfo.playlist;
913 offset = segmentInfo.offset; 923 offset = segmentInfo.offset;
...@@ -970,31 +980,6 @@ videojs.Hls.prototype.drainBuffer = function(event) { ...@@ -970,31 +980,6 @@ videojs.Hls.prototype.drainBuffer = function(event) {
970 this.addCuesForMetadata_(segmentInfo); 980 this.addCuesForMetadata_(segmentInfo);
971 //this.updateDuration(this.playlists.media()); 981 //this.updateDuration(this.playlists.media());
972 982
973
974 // // if we're refilling the buffer after a seek, scan through the muxed
975 // // FLV tags until we find the one that is closest to the desired
976 // // playback time
977 // if (typeof offset === 'number') {
978 // if (tags.length) {
979 // // determine the offset within this segment we're seeking to
980 // segmentOffset = this.playlists.expiredPostDiscontinuity_ + this.playlists.expiredPreDiscontinuity_;
981 // segmentOffset += videojs.Hls.Playlist.duration(playlist,
982 // playlist.mediaSequence,
983 // playlist.mediaSequence + mediaIndex);
984 // segmentOffset = offset - (segmentOffset * 1000);
985 // ptsTime = segmentOffset + tags[0].pts;
986
987 // while (tags[i + 1] && tags[i].pts < ptsTime) {
988 // i++;
989 // }
990
991 // // tell the SWF the media position of the first tag we'll be delivering
992 // this.tech_.el().vjs_setProperty('currentTime', ((tags[i].pts - ptsTime + offset) * 0.001));
993
994 // tags = tags.slice(i);
995 // }
996 // }
997
998 // // when we're crossing a discontinuity, inject metadata to indicate 983 // // when we're crossing a discontinuity, inject metadata to indicate
999 // // that the decoder should be reset appropriately 984 // // that the decoder should be reset appropriately
1000 // if (segment.discontinuity && tags.length) { 985 // if (segment.discontinuity && tags.length) {
......
...@@ -6,9 +6,6 @@ if (process.env.SAUCE_USERNAME) { ...@@ -6,9 +6,6 @@ if (process.env.SAUCE_USERNAME) {
6 config.multiCapabilities = [{ 6 config.multiCapabilities = [{
7 browserName: 'chrome', 7 browserName: 'chrome',
8 platform: 'Windows 8.1' 8 platform: 'Windows 8.1'
9 }, {
10 browserName: 'firefox',
11 platform: 'Windows 8.1'
12 }].map(function(caps) { 9 }].map(function(caps) {
13 caps.name = process.env.TRAVIS_BUILD_NUMBER + process.env.TRAVIS_BRANCH; 10 caps.name = process.env.TRAVIS_BUILD_NUMBER + process.env.TRAVIS_BRANCH;
14 caps.build = process.env.TRAVIS_BUILD_NUMBER; 11 caps.build = process.env.TRAVIS_BUILD_NUMBER;
......
...@@ -60,7 +60,7 @@ module.exports = function(config) { ...@@ -60,7 +60,7 @@ module.exports = function(config) {
60 customLaunchers: customLaunchers, 60 customLaunchers: customLaunchers,
61 61
62 // Start these browsers 62 // Start these browsers
63 browsers: ['chrome_sl', 'firefox_sl'], //Object.keys(customLaunchers), 63 browsers: ['chrome_sl'], //Object.keys(customLaunchers),
64 64
65 // List of files / patterns to load in the browser 65 // List of files / patterns to load in the browser
66 // Add any new src files to this list. 66 // Add any new src files to this list.
......