-
Notifications
You must be signed in to change notification settings - Fork 311
HLS Segment Edge Seeking #71
Changes from 6 commits
c5098ca
2863c58
95922dd
7ccde9b
52a3b45
37b9470
fc7bf62
89c6358
c85bc3c
988981f
c6ccbc7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,15 +10,16 @@ package com.videojs{ | |
import com.videojs.structs.ExternalEventName; | ||
import com.videojs.structs.PlaybackType; | ||
import com.videojs.structs.PlayerMode; | ||
|
||
import flash.events.Event; | ||
import flash.events.EventDispatcher; | ||
import flash.external.ExternalInterface; | ||
import flash.geom.Rectangle; | ||
import flash.media.SoundMixer; | ||
import flash.media.SoundTransform; | ||
import flash.media.Video; | ||
import flash.utils.ByteArray; | ||
import flash.net.NetStreamAppendBytesAction; | ||
import flash.utils.ByteArray; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The indent is off on these There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed. |
||
|
||
public class VideoJSModel extends EventDispatcher{ | ||
|
||
|
@@ -43,9 +44,10 @@ 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; | ||
|
||
public function VideoJSModel(pLock:SingletonLock){ | ||
if (!pLock is SingletonLock) { | ||
throw new Error("Invalid Singleton access. Use VideoJSModel.getInstance()!"); | ||
|
@@ -64,11 +66,20 @@ 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; | ||
} | ||
public function set mode(pMode:String):void{ | ||
|
||
public function set mode(pMode:String):void { | ||
switch(pMode){ | ||
case PlayerMode.VIDEO: | ||
_mode = pMode; | ||
|
@@ -84,32 +95,32 @@ package com.videojs{ | |
public function get jsEventProxyName():String{ | ||
return _jsEventProxyName; | ||
} | ||
public function set jsEventProxyName(pName:String):void{ | ||
public function set jsEventProxyName(pName:String):void { | ||
_jsEventProxyName = cleanEIString(pName); | ||
} | ||
|
||
public function get jsErrorEventProxyName():String{ | ||
return _jsErrorEventProxyName; | ||
} | ||
public function set jsErrorEventProxyName(pName:String):void{ | ||
public function set jsErrorEventProxyName(pName:String):void { | ||
_jsErrorEventProxyName = cleanEIString(pName); | ||
} | ||
|
||
public function get stageRect():Rectangle{ | ||
return _stageRect; | ||
} | ||
public function set stageRect(pRect:Rectangle):void{ | ||
public function set stageRect(pRect:Rectangle):void { | ||
_stageRect = pRect; | ||
} | ||
|
||
public function appendBuffer(bytes:ByteArray):void{ | ||
public function appendBuffer(bytes:ByteArray):void { | ||
_provider.appendBuffer(bytes); | ||
} | ||
|
||
public function get backgroundColor():Number{ | ||
return _backgroundColor; | ||
} | ||
public function set backgroundColor(pColor:Number):void{ | ||
public function set backgroundColor(pColor:Number):void { | ||
if(pColor < 0){ | ||
_backgroundColor = 0; | ||
} | ||
|
@@ -122,7 +133,7 @@ package com.videojs{ | |
public function get backgroundAlpha():Number{ | ||
return _backgroundAlpha; | ||
} | ||
public function set backgroundAlpha(pAlpha:Number):void{ | ||
public function set backgroundAlpha(pAlpha:Number):void { | ||
if(pAlpha < 0){ | ||
_backgroundAlpha = 0; | ||
} | ||
|
@@ -134,7 +145,7 @@ package com.videojs{ | |
public function get videoReference():Video{ | ||
return _videoReference; | ||
} | ||
public function set videoReference(pVideo:Video):void{ | ||
public function set videoReference(pVideo:Video):void { | ||
_videoReference = pVideo; | ||
} | ||
|
||
|
@@ -148,7 +159,7 @@ package com.videojs{ | |
public function get volume():Number{ | ||
return _volume; | ||
} | ||
public function set volume(pVolume:Number):void{ | ||
public function set volume(pVolume:Number):void { | ||
if(pVolume >= 0 && pVolume <= 1){ | ||
_volume = pVolume; | ||
} | ||
|
@@ -167,11 +178,17 @@ package com.videojs{ | |
} | ||
return 0; | ||
} | ||
|
||
public function set duration(value:Number):void { | ||
if(_provider && _provider is HTTPVideoProvider) { | ||
(_provider as HTTPVideoProvider).duration = value; | ||
} | ||
} | ||
|
||
public function get autoplay():Boolean{ | ||
return _autoplay; | ||
} | ||
public function set autoplay(pValue:Boolean):void{ | ||
public function set autoplay(pValue:Boolean):void { | ||
_autoplay = pValue; | ||
} | ||
|
||
|
@@ -181,7 +198,7 @@ package com.videojs{ | |
} | ||
return _src; | ||
} | ||
public function set src(pValue:String):void{ | ||
public function set src(pValue:String):void { | ||
_src = pValue; | ||
_rtmpConnectionURL = ""; | ||
_rtmpStream = ""; | ||
|
@@ -199,15 +216,15 @@ package com.videojs{ | |
public function get rtmpConnectionURL():String{ | ||
return _rtmpConnectionURL; | ||
} | ||
public function set rtmpConnectionURL(pURL:String):void{ | ||
public function set rtmpConnectionURL(pURL:String):void { | ||
_src = ""; | ||
_rtmpConnectionURL = pURL; | ||
} | ||
|
||
public function get rtmpStream():String{ | ||
return _rtmpStream; | ||
} | ||
public function set rtmpStream(pValue:String):void{ | ||
public function set rtmpStream(pValue:String):void { | ||
_src = ""; | ||
_rtmpStream = pValue; | ||
broadcastEventExternally(ExternalEventName.ON_SRC_CHANGE, _src); | ||
|
@@ -235,7 +252,7 @@ package com.videojs{ | |
* @param pValue | ||
* | ||
*/ | ||
public function set srcFromFlashvars(pValue:String):void{ | ||
public function set srcFromFlashvars(pValue:String):void { | ||
_src = pValue; | ||
_currentPlaybackType = PlaybackType.HTTP | ||
initProvider(); | ||
|
@@ -251,7 +268,7 @@ package com.videojs{ | |
public function get poster():String{ | ||
return _poster; | ||
} | ||
public function set poster(pValue:String):void{ | ||
public function set poster(pValue:String):void { | ||
_poster = pValue; | ||
broadcastEvent(new VideoJSEvent(VideoJSEvent.POSTER_SET)); | ||
} | ||
|
@@ -270,15 +287,21 @@ package com.videojs{ | |
*/ | ||
public function get time():Number{ | ||
if(_provider){ | ||
return _provider.time; | ||
if(_provider is HTTPVideoProvider && _src == null) | ||
{ | ||
//ExternalInterface.call('console.log', 'SWF Time', _lastSeekedTime, _provider.time); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this comment need to be left in? Also, would it be good to document what this function is doing now and why? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comment removed |
||
return _lastSeekedTime + _provider.time; | ||
} else { | ||
return _provider.time; | ||
} | ||
} | ||
return 0; | ||
} | ||
|
||
public function get muted():Boolean{ | ||
return (_volume == 0); | ||
} | ||
public function set muted(pValue:Boolean):void{ | ||
public function set muted(pValue:Boolean):void { | ||
if(pValue){ | ||
var __lastSetVolume:Number = _lastSetVolume; | ||
volume = 0; | ||
|
@@ -314,20 +337,20 @@ package com.videojs{ | |
public function get preload():Boolean{ | ||
return _preload; | ||
} | ||
public function set preload(pValue:Boolean):void{ | ||
public function set preload(pValue:Boolean):void { | ||
_preload = pValue; | ||
} | ||
|
||
public function get loop():Boolean{ | ||
return _loop; | ||
} | ||
public function set loop(pValue:Boolean):void{ | ||
public function set loop(pValue:Boolean):void { | ||
_loop = pValue; | ||
} | ||
|
||
public function get buffered():Number{ | ||
if(_provider){ | ||
return _provider.buffered; | ||
return time + _provider.buffered; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like a significant change. Are we sure this won't break the normal buffered operation, e.g. with plain mp4 playback? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will defer to @dmlap on this one. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line is a bug but I believe it was fixed in a later commit. I would recommend waiting a little bit longer before pulling any of the HLS-related SWF changes into master. I'm still in the middle of testing everything. |
||
} | ||
return 0; | ||
} | ||
|
@@ -404,7 +427,7 @@ package com.videojs{ | |
* @param e | ||
* | ||
*/ | ||
public function broadcastEvent(e:Event):void{ | ||
public function broadcastEvent(e:Event):void { | ||
dispatchEvent(e); | ||
} | ||
|
||
|
@@ -413,7 +436,7 @@ package com.videojs{ | |
* @param args | ||
* | ||
*/ | ||
public function broadcastEventExternally(... args):void{ | ||
public function broadcastEventExternally(... args):void { | ||
if(_jsEventProxyName != ""){ | ||
if(ExternalInterface.available){ | ||
var __incomingArgs:* = args as Array; | ||
|
@@ -428,7 +451,7 @@ package com.videojs{ | |
* @param args | ||
* | ||
*/ | ||
public function broadcastErrorEventExternally(... args):void{ | ||
public function broadcastErrorEventExternally(... args):void { | ||
if(_jsErrorEventProxyName != ""){ | ||
if(ExternalInterface.available){ | ||
var __incomingArgs:* = args as Array; | ||
|
@@ -442,7 +465,7 @@ package com.videojs{ | |
* Loads the video in a paused state. | ||
* | ||
*/ | ||
public function load():void{ | ||
public function load():void { | ||
if(_provider){ | ||
_provider.load(); | ||
} | ||
|
@@ -452,7 +475,7 @@ package com.videojs{ | |
* Loads the video and begins playback immediately. | ||
* | ||
*/ | ||
public function play():void{ | ||
public function play():void { | ||
if(_provider){ | ||
_provider.play(); | ||
} | ||
|
@@ -462,7 +485,7 @@ package com.videojs{ | |
* Pauses video playback. | ||
* | ||
*/ | ||
public function pause():void{ | ||
public function pause():void { | ||
if(_provider){ | ||
_provider.pause(); | ||
} | ||
|
@@ -472,7 +495,7 @@ package com.videojs{ | |
* Resumes video playback. | ||
* | ||
*/ | ||
public function resume():void{ | ||
public function resume():void { | ||
if(_provider){ | ||
_provider.resume(); | ||
} | ||
|
@@ -483,7 +506,11 @@ package com.videojs{ | |
* @param pValue | ||
* | ||
*/ | ||
public function seekBySeconds(pValue:Number):void{ | ||
public function seekBySeconds(pValue:Number):void { | ||
ExternalInterface.call('console.log', 'SWF Received SeekValue', pValue); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We shouldn't leave console.log statements in the final version. At minimum it can throw an error in oldIE. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed. |
||
|
||
_lastSeekedTime = pValue; | ||
|
||
if(_provider){ | ||
_provider.seekBySeconds(pValue); | ||
} | ||
|
@@ -494,7 +521,7 @@ package com.videojs{ | |
* @param pValue A float from 0 to 1 that represents the desired seek percent. | ||
* | ||
*/ | ||
public function seekByPercent(pValue:Number):void{ | ||
public function seekByPercent(pValue:Number):void { | ||
if(_provider){ | ||
_provider.seekByPercent(pValue); | ||
} | ||
|
@@ -504,7 +531,7 @@ package com.videojs{ | |
* Stops video playback, clears the video element, and stops any loading proceeses. | ||
* | ||
*/ | ||
public function stop():void{ | ||
public function stop():void { | ||
if(_provider){ | ||
_provider.stop(); | ||
} | ||
|
@@ -539,7 +566,7 @@ package com.videojs{ | |
return pString.replace(/[^A-Za-z0-9_.]/gi, ""); | ||
} | ||
|
||
private function initProvider():void{ | ||
private function initProvider():void { | ||
if(_provider){ | ||
_provider.die(); | ||
_provider = null; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would there be any way we could load this version number in dynamically from the package.json?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be able to yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't need to happen now, but that would be cool to set up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#75