diff --git a/dist/video-js.swf b/dist/video-js.swf index ed18e3d5..eb9b4e50 100644 Binary files a/dist/video-js.swf and b/dist/video-js.swf differ diff --git a/src/VideoJS.as b/src/VideoJS.as index 3002b7a9..576f5eb1 100644 --- a/src/VideoJS.as +++ b/src/VideoJS.as @@ -71,6 +71,8 @@ package{ ExternalInterface.addCallback("vjs_appendBuffer", onAppendBufferCalled); ExternalInterface.addCallback("vjs_echo", onEchoCalled); ExternalInterface.addCallback("vjs_endOfStream", onEndOfStreamCalled); + ExternalInterface.addCallback("vjs_abort", onAbortCalled); + ExternalInterface.addCallback("vjs_getProperty", onGetPropertyCalled); ExternalInterface.addCallback("vjs_setProperty", onSetPropertyCalled); ExternalInterface.addCallback("vjs_autoplay", onAutoplayCalled); @@ -191,6 +193,10 @@ package{ private function onEndOfStreamCalled():*{ _app.model.endOfStream(); } + + private function onAbortCalled():*{ + _app.model.abort(); + } private function onGetPropertyCalled(pPropertyName:String = ""):*{ diff --git a/src/com/videojs/VideoJSModel.as b/src/com/videojs/VideoJSModel.as index 5b4ec2eb..4903b1dd 100644 --- a/src/com/videojs/VideoJSModel.as +++ b/src/com/videojs/VideoJSModel.as @@ -110,6 +110,10 @@ package com.videojs{ public function endOfStream():void { _provider.endOfStream(); } + + public function abort():void { + _provider.abort(); + } public function get backgroundColor():Number{ return _backgroundColor; diff --git a/src/com/videojs/providers/HTTPAudioProvider.as b/src/com/videojs/providers/HTTPAudioProvider.as index ea7f2b22..c96046c5 100644 --- a/src/com/videojs/providers/HTTPAudioProvider.as +++ b/src/com/videojs/providers/HTTPAudioProvider.as @@ -118,6 +118,10 @@ package com.videojs.providers{ public function endOfStream():void{ throw "HTTPAudioProvider does not support endOfStream"; } + + public function abort():void{ + throw "HTTPAudioProvider does not support abort"; + } public function get buffered():Number{ if(duration > 0){ diff --git a/src/com/videojs/providers/HTTPVideoProvider.as b/src/com/videojs/providers/HTTPVideoProvider.as index 3656bbe3..ce0351e8 100644 --- a/src/com/videojs/providers/HTTPVideoProvider.as +++ b/src/com/videojs/providers/HTTPVideoProvider.as @@ -1,5 +1,5 @@ package com.videojs.providers{ - + import com.videojs.VideoJSModel; import com.videojs.events.VideoPlaybackEvent; import com.videojs.structs.ExternalErrorEventName; @@ -173,6 +173,11 @@ package com.videojs.providers{ public function endOfStream():void{ _ending = true; } + + public function abort():void{ + // flush the netstream buffers + _ns.seek(time); + } public function get buffered():Number{ // _src.path == null when in data generation mode @@ -321,13 +326,15 @@ package com.videojs.providers{ _hasEnded = false; } + _isBuffering = true; + if(_src.path === null) { _startOffset = pTime; + return; } _ns.seek(pTime); - _isBuffering = true; } @@ -402,6 +409,9 @@ package com.videojs.providers{ } private function initNetConnection():void{ + // the video element triggers loadstart as soon as the resource selection algorithm selects a source + // this is somewhat later than that moment but relatively close + _model.broadcastEventExternally(ExternalEventName.ON_LOAD_START); if(_nc != null) { try { @@ -491,8 +501,6 @@ package com.videojs.providers{ _loadStartTimestamp = getTimer(); _throughputTimer.reset(); _throughputTimer.start(); - _model.broadcastEventExternally(ExternalEventName.ON_LOAD_START); - _model.broadcastEventExternally(ExternalEventName.ON_BUFFER_EMPTY); if(_pauseOnStart && _loadStarted == false){ _ns.pause(); _isPaused = true; diff --git a/src/com/videojs/providers/IProvider.as b/src/com/videojs/providers/IProvider.as index 523c949f..61739f2a 100644 --- a/src/com/videojs/providers/IProvider.as +++ b/src/com/videojs/providers/IProvider.as @@ -37,6 +37,12 @@ package com.videojs.providers{ * of buffered input is equivalent to the end of the media. */ function endOfStream():void; + + /** + * Aborts any data currently in the buffer and resets the decoder. + * @see https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source.html#widl-SourceBuffer-abort-void + */ + function abort():void; /** * Should return an interger that reflects the closest parallel to diff --git a/src/com/videojs/providers/RTMPVideoProvider.as b/src/com/videojs/providers/RTMPVideoProvider.as index b6d329e5..1fd4a2d0 100644 --- a/src/com/videojs/providers/RTMPVideoProvider.as +++ b/src/com/videojs/providers/RTMPVideoProvider.as @@ -141,6 +141,10 @@ package com.videojs.providers{ public function endOfStream():void{ throw "RTMPVideoProvider does not support endOfStream"; } + + public function abort():void{ + throw "RTMPVideoProvider does not support abort"; + } public function get buffered():Number{ if(duration > 0){