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

Commit

Permalink
Capture seek target in HTTPVideoProvider
Browse files Browse the repository at this point in the history
Instead of requiring an explicit call into the SWF to set the new starting offset for the netstream time, capture it when seekForSeconds is called in HTTPVideoProvider.
  • Loading branch information
dmlap committed Jan 23, 2014
1 parent c85bc3c commit 988981f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 26 deletions.
6 changes: 0 additions & 6 deletions src/VideoJS.as
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,6 @@ package{
private function onGetPropertyCalled(pPropertyName:String = ""):*{

switch(pPropertyName){
case "lastSeekedTime":
return _app.model.lastSeekedTime;
break;
case "mode":
return _app.model.mode;
case "autoplay":
Expand Down Expand Up @@ -277,9 +274,6 @@ package{

private function onSetPropertyCalled(pPropertyName:String = "", pValue:* = null):void{
switch(pPropertyName){
case "lastSeekedTime":
_app.model.lastSeekedTime = Number(pValue);
break;
case "duration":
_app.model.duration = Number(pValue);
break;
Expand Down
20 changes: 2 additions & 18 deletions src/com/videojs/VideoJSModel.as
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ package com.videojs{
private var _rtmpConnectionURL:String = "";
private var _rtmpStream:String = "";
private var _poster:String = "";
private var _lastSeekedTime:Number = 0;

private static var _instance:VideoJSModel;

Expand All @@ -66,14 +65,6 @@ package com.videojs{
return _instance;
}

public function get lastSeekedTime():Number {
return _lastSeekedTime;
}

public function set lastSeekedTime(value:Number):void {
_lastSeekedTime = value;
}

public function get mode():String{
return _mode;
}
Expand Down Expand Up @@ -286,12 +277,7 @@ package com.videojs{
*/
public function get time():Number{
if(_provider){
if(_provider is HTTPVideoProvider && _src == null)
{
return _lastSeekedTime + _provider.time;
} else {
return _provider.time;
}
return _provider.time;
}
return 0;
}
Expand Down Expand Up @@ -348,7 +334,7 @@ package com.videojs{

public function get buffered():Number{
if(_provider){
return _lastSeekedTime + _provider.buffered;
return _provider.buffered;
}
return 0;
}
Expand Down Expand Up @@ -505,8 +491,6 @@ package com.videojs{
*
*/
public function seekBySeconds(pValue:Number):void {
_lastSeekedTime = pValue;

if(_provider){
_provider.seekBySeconds(pValue);
}
Expand Down
19 changes: 17 additions & 2 deletions src/com/videojs/providers/HTTPVideoProvider.as
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ package com.videojs.providers{
private var _loadErrored:Boolean = false;
private var _pauseOnStart:Boolean = false;
private var _pausePending:Boolean = false;
/**
* The number of seconds between the logical start of the stream and the current zero
* playhead position of the NetStream. During normal, file-based playback this value should
* always be zero. When the NetStream is in data generation mode, seeking during playback
* resets the zero point of the stream to the seek target. To recover the playhead position
* in the logical stream, this value can be added to the NetStream reported time.
*
* @see http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/NetStream.html#play()
*/
private var _startOffset:Number = 0;
private var _videoReference:Video;

/**
Expand Down Expand Up @@ -72,7 +82,7 @@ package com.videojs.providers{
return _pausedSeekValue;
}
else{
return _ns.time;
return _startOffset + _ns.time;
}
}
else{
Expand Down Expand Up @@ -158,7 +168,7 @@ package com.videojs.providers{
// _src.path == null when in data generation mode
if(_ns && _src.path == null)
{
return _ns.bufferLength + _ns.time;
return _startOffset + _ns.bufferLength + _ns.time;
} else if(duration > 0){
return (_ns.bytesLoaded / _ns.bytesTotal) * duration;
} else {
Expand Down Expand Up @@ -301,6 +311,11 @@ package com.videojs.providers{
_hasEnded = false;
}

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

_ns.seek(pTime);
_isBuffering = true;

Expand Down

0 comments on commit 988981f

Please sign in to comment.