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

loadstart should fire during the resource selection algorithm #93

Merged
merged 3 commits into from
May 23, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should time be here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It depends on whether the netstream requires an input value or not. We're basically forcing it to flush the buffers by calling seek to the current time. It's possible we could just call _ns.seek() but having time there shouldn't make a difference, really.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NetStream.seek requires an offset time as a parameter ( per API reference: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/NetStream.html#seek() ). Buffer flushing is normalized as NetStream.seek(currentTime).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But where is time defined? It's at least not clear from what I'm looking at.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that's the time it's referring to, should it be _ns.seek(time()) then? Or do class property getters always execute? I really don't know action script...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This syntax is correct within actionscript when the originating function is explicitly set as a getter. Least that's how I remember it, it's been a while since I was in here :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ha, ok. ignore me then

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, yeah, we had this problem also.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think getters are a terrible language feature in general because they're so easy to abuse but when in Rome...

}

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