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

Commit

Permalink
Merge pull request #93 from videojs/hotfix/loadstart
Browse files Browse the repository at this point in the history
loadstart should fire during the resource selection algorithm
  • Loading branch information
dmlap committed May 23, 2014
2 parents f178ab8 + 6448a5e commit 31d78a8
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 4 deletions.
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
16 changes: 12 additions & 4 deletions src/com/videojs/providers/HTTPVideoProvider.as
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.videojs.providers{

import com.videojs.VideoJSModel;
import com.videojs.events.VideoPlaybackEvent;
import com.videojs.structs.ExternalErrorEventName;
Expand Down 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 Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
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 31d78a8

Please sign in to comment.