Skip to content
This repository has been archived by the owner on Dec 10, 2020. It is now read-only.

Commit

Permalink
Add a mechanism to emulate SourceBuffer.abort()
Browse files Browse the repository at this point in the history
Calling abort() on a source buffer resets the decoder buffers. Instead of relying on this happening implicitly through seeking, add a method so that media sources can trigger it directly.
  • Loading branch information
dmlap committed May 22, 2014
1 parent 4f5136a commit 6448a5e
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 1 deletion.
Binary file modified dist/video-js.swf
Binary file not shown.
6 changes: 6 additions & 0 deletions src/VideoJS.as
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -191,6 +193,10 @@ package{
private function onEndOfStreamCalled():*{
_app.model.endOfStream();
}

private function onAbortCalled():*{
_app.model.abort();
}

private function onGetPropertyCalled(pPropertyName:String = ""):*{

Expand Down
4 changes: 4 additions & 0 deletions src/com/videojs/VideoJSModel.as
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/com/videojs/providers/HTTPAudioProvider.as
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
9 changes: 8 additions & 1 deletion src/com/videojs/providers/HTTPVideoProvider.as
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -321,13 +326,15 @@ package com.videojs.providers{
_hasEnded = false;
}

_isBuffering = true;

if(_src.path === null)
{
_startOffset = pTime;
return;
}

_ns.seek(pTime);
_isBuffering = true;

}

Expand Down
6 changes: 6 additions & 0 deletions src/com/videojs/providers/IProvider.as
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/com/videojs/providers/RTMPVideoProvider.as
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down

0 comments on commit 6448a5e

Please sign in to comment.