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 @@
"grunt-github-releaser": "^0.1.17",
"grunt-karma": "~0.6.2",
"grunt-open": "0.2.3",
"grunt-protractor-runner": "git+https://github.com/forbesjo/grunt-protractor-runner.git#webdriverManagerUpdate",
"grunt-protractor-runner": "forbesjo/grunt-protractor-runner.git#webdriverManagerUpdate",
"grunt-shell": "0.6.1",
"grunt-version": "^1.0.0",
"karma": "~0.10.0",
......@@ -48,7 +48,7 @@
},
"dependencies": {
"pkcs7": "^0.2.2",
"videojs-contrib-media-sources": "git+ssh://git@github.com:videojs/videojs-contrib-media-sources.git#mse-mp2t-polyfill",
"videojs-contrib-media-sources": "videojs/videojs-contrib-media-sources.git#mse-mp2t-polyfill",
"videojs-swf": "5.0.0-rc0"
}
}
......
......@@ -131,6 +131,12 @@ videojs.Hls.prototype.src = function(src) {
// load the MediaSource into the player
this.mediaSource.addEventListener('sourceopen', this.handleSourceOpen.bind(this));
// We need to trigger this asynchronously to give others the chance
// to bind to the event when a source is set at player creation
setTimeout(function() {
this.tech_.trigger('loadstart');
}.bind(this), 1);
// The index of the next segment to be downloaded in the current
// media playlist. When the current media playlist is live with
// expiring segments, it may be a different value from the media
......@@ -210,6 +216,14 @@ videojs.Hls.prototype.src = function(src) {
}.bind(this));
this.playlists.on('error', function() {
// close the media source with the appropriate error type
if (this.playlists.error.code === 2) {
this.mediaSource.endOfStream('network');
} else if (this.playlists.error.code === 4) {
this.mediaSource.endOfStream('decode');
}
// if this error is unrecognized, pass it along to the tech
this.tech_.error(this.playlists.error);
}.bind(this));
......@@ -425,7 +439,7 @@ videojs.Hls.prototype.play = function() {
// if the viewer has paused and we fell out of the live window,
// seek forward to the earliest available position
if (this.tech_.duration() === Infinity) {
if (this.duration() === Infinity) {
if (this.tech_.currentTime() < this.tech_.seekable().start(0)) {
this.tech_.setCurrentTime(this.tech_.seekable().start(0));
}
......@@ -903,11 +917,7 @@ videojs.Hls.prototype.drainBuffer = function(event) {
return;
}
segmentInfo = segmentBuffer[0];
mediaIndex = segmentInfo.mediaIndex;
playlist = segmentInfo.playlist;
offset = segmentInfo.offset;
......@@ -970,31 +980,6 @@ videojs.Hls.prototype.drainBuffer = function(event) {
this.addCuesForMetadata_(segmentInfo);
//this.updateDuration(this.playlists.media());
// // if we're refilling the buffer after a seek, scan through the muxed
// // FLV tags until we find the one that is closest to the desired
// // playback time
// if (typeof offset === 'number') {
// if (tags.length) {
// // determine the offset within this segment we're seeking to
// segmentOffset = this.playlists.expiredPostDiscontinuity_ + this.playlists.expiredPreDiscontinuity_;
// segmentOffset += videojs.Hls.Playlist.duration(playlist,
// playlist.mediaSequence,
// playlist.mediaSequence + mediaIndex);
// segmentOffset = offset - (segmentOffset * 1000);
// ptsTime = segmentOffset + tags[0].pts;
// while (tags[i + 1] && tags[i].pts < ptsTime) {
// i++;
// }
// // tell the SWF the media position of the first tag we'll be delivering
// this.tech_.el().vjs_setProperty('currentTime', ((tags[i].pts - ptsTime + offset) * 0.001));
// tags = tags.slice(i);
// }
// }
// // when we're crossing a discontinuity, inject metadata to indicate
// // that the decoder should be reset appropriately
// if (segment.discontinuity && tags.length) {
......
......@@ -6,9 +6,6 @@ if (process.env.SAUCE_USERNAME) {
config.multiCapabilities = [{
browserName: 'chrome',
platform: 'Windows 8.1'
}, {
browserName: 'firefox',
platform: 'Windows 8.1'
}].map(function(caps) {
caps.name = process.env.TRAVIS_BUILD_NUMBER + process.env.TRAVIS_BRANCH;
caps.build = process.env.TRAVIS_BUILD_NUMBER;
......
......@@ -60,7 +60,7 @@ module.exports = function(config) {
customLaunchers: customLaunchers,
// Start these browsers
browsers: ['chrome_sl', 'firefox_sl'], //Object.keys(customLaunchers),
browsers: ['chrome_sl'], //Object.keys(customLaunchers),
// List of files / patterns to load in the browser
// Add any new src files to this list.
......