diff --git a/src/js/media/html5.js b/src/js/media/html5.js
index 66fcdb158..19dcc3cf7 100644
--- a/src/js/media/html5.js
+++ b/src/js/media/html5.js
@@ -29,12 +29,8 @@ vjs.Html5 = vjs.MediaTechController.extend({
var source = options['source'];
- // If the element source is already set, we may have missed the loadstart event, and want to trigger it.
- // We don't want to set the source again and interrupt playback.
- if (source && this.el_.currentSrc === source.src && this.el_.networkState > 0) {
- player.trigger('loadstart');
- // Otherwise set the source if one was provided.
- } else if (source) {
+ // set the source if one was provided
+ if (source && this.el_.currentSrc !== source.src) {
this.el_.src = source.src;
}
@@ -247,6 +243,8 @@ vjs.Html5.prototype.defaultMuted = function(){ return this.el_.defaultMuted; };
vjs.Html5.prototype.playbackRate = function(){ return this.el_.playbackRate; };
vjs.Html5.prototype.setPlaybackRate = function(val){ this.el_.playbackRate = val; };
+vjs.Html5.prototype.networkState = function(){ return this.el_.networkState; };
+
/* HTML5 Support Testing ---------------------------------------------------- */
vjs.Html5.isSupported = function(){
diff --git a/src/js/media/media.js b/src/js/media/media.js
index 47a69eb1e..0ea37cbea 100644
--- a/src/js/media/media.js
+++ b/src/js/media/media.js
@@ -61,6 +61,17 @@ vjs.MediaTechController.prototype.initControlsListeners = function(){
this.ready(activateControls);
player.on('controlsenabled', activateControls);
player.on('controlsdisabled', deactivateControls);
+
+ // if we're loading the playback object after it has started loading or playing the
+ // video (often with autoplay on) then the loadstart event has already fired and we
+ // need to fire it manually because many things rely on it.
+ // Long term we might consider how we would do this for other events like 'canplay'
+ // that may also have fired.
+ this.ready(function(){
+ if (this.networkState && this.networkState() > 0) {
+ this.player().trigger('loadstart');
+ }
+ });
};
vjs.MediaTechController.prototype.addControlsListeners = function(){
@@ -161,21 +172,3 @@ vjs.MediaTechController.prototype.features = {
};
vjs.media = {};
-
-/**
- * List of default API methods for any MediaTechController
- * @type {String}
- */
-vjs.media.ApiMethods = 'play,pause,paused,currentTime,setCurrentTime,duration,buffered,volume,setVolume,muted,setMuted,width,height,supportsFullScreen,enterFullScreen,src,load,currentSrc,preload,setPreload,autoplay,setAutoplay,loop,setLoop,error,networkState,readyState,seeking,initialTime,startOffsetTime,played,seekable,ended,videoTracks,audioTracks,videoWidth,videoHeight,textTracks,defaultPlaybackRate,playbackRate,mediaGroup,controller,controls,defaultMuted'.split(',');
-// Create placeholder methods for each that warn when a method isn't supported by the current playback technology
-
-function createMethod(methodName){
- return function(){
- throw new Error('The "'+methodName+'" method is not available on the playback technology\'s API');
- };
-}
-
-for (var i = vjs.media.ApiMethods.length - 1; i >= 0; i--) {
- var methodName = vjs.media.ApiMethods[i];
- vjs.MediaTechController.prototype[vjs.media.ApiMethods[i]] = createMethod(methodName);
-}