Commit 04ba4cea authored by Daniel Rossi's avatar Daniel Rossi

- #163 optimise timers on autohide and scrubber slider. fix issues with...

- #163 optimise timers on autohide and scrubber slider. fix issues with directly adding clips and in stream clips on the playlist changes.
- #163 disable error dispatches on the animation library around the easing setter.
parent 185626d5
......@@ -20,13 +20,14 @@
* THE SOFTWARE.
*/
package org.goasap.items {
import flash.utils.getTimer;
import flash.utils.getTimer;
import org.goasap.GoEngine;
import org.goasap.errors.EasingFormatError;
import org.goasap.events.GoEvent;
import org.goasap.interfaces.IPlayable;
import org.goasap.managers.LinearGoRepeater;
import org.goasap.managers.LinearGoRepeater;
/**
* Dispatched during an animation's first update after the delay
......@@ -262,13 +263,14 @@ package org.goasap.items {
}
public function set easing(type:Function):void {
if (_state==STOPPED) {
try {
//try {
if (type(1,1,1,1) is Number) {
_easing = type;
return;
}
} catch (e:Error) {}
throw new EasingFormatError();
//} catch (e:Error) {}
//#163 don't throw an error just because.
//throw new EasingFormatError();
}
}
......@@ -496,18 +498,25 @@ package org.goasap.items {
defaultDelay = 0;
if (isNaN(defaultDuration))
defaultDuration = 1;
try { this.easing = defaultEasing; }
catch (e1:EasingFormatError) { defaultEasing = easeOut; }
/*try { this.easing = defaultEasing; }
catch (e1:EasingFormatError) { defaultEasing = easeOut; } */
//#163 set default easing
this.easing = easeOut;
// set params
if (!isNaN(delay)) _delay = delay;
else _delay = defaultDelay;
if (!isNaN(duration)) _duration = duration;
else _duration = defaultDuration;
try { this.easing = easing; }
/*try { this.easing = easing; }
catch (e2:EasingFormatError) {
if (easing!=null) { throw e2; } // user passed invalid easing function
this.easing = defaultEasing;
}
}*/
//if (easing && easing)
//#163 set easing if enabled on the argument, not needed for normal Flowplayer animations.
if (easing!=null) this.easing = easing;
if (extraEasingParams) _extraEaseParams = extraEasingParams;
if (useRelative) this.useRelative = true;
if (useRounding) this.useRounding = true;
......
......@@ -21,6 +21,7 @@ package org.flowplayer.model {
import org.flowplayer.flow_internal;
use namespace flow_internal;
/**
* @author anssi
......@@ -81,7 +82,7 @@ package org.flowplayer.model {
var oldClips:Array = _clips.concat([]);
//#163 detach netstream on the current clip
if (_clips[_currentPos].getContent().hasOwnProperty("attachNetStream")) {
if (_clips[_currentPos] && _clips[_currentPos].getContent().hasOwnProperty("attachNetStream")) {
_clips[_currentPos].getContent().attachNetStream(null);
}
......@@ -146,6 +147,7 @@ package org.flowplayer.model {
if (pos == -1) {
pos = clips.length - 1;
}
var parent:Clip = clips[pos];
parent.addChild(clip);
if (clip.position == 0) {
......@@ -173,17 +175,19 @@ package org.flowplayer.model {
clip.onBeforeAll(_commonClip.onBeforeClipEvent);
}
for (var i:int = 0; i < clip.playlist.length; i++) {
addChildClip(clip.playlist[i], pos, dispatchEvents);
}
//log.debug("clips now " + _clips);
if (pos == -1) {
_clips.push(clip);
} else {
_clips.splice(_clips.indexOf(clips[pos].preroll || clips[pos]), 0, clip);
_clips.splice(_clips.indexOf(_clips[pos].preroll || _clips[pos]), 0, clip);
}
var nested:Array = clip.playlist;
for (var i:int = 0; i < nested.length; i++) {
addChildClip(nested[i], pos, dispatchEvents);
}
//log.debug("clips now " + _clips);
}
/**
......
......@@ -354,21 +354,23 @@ package org.flowplayer.ui {
}
if (! _hideTimer) {
_hideTimer = new Timer(_config.hideDelay);
_hideTimer.addEventListener(TimerEvent.TIMER, hide);
}
// check if hideDelay has changed
else if (_config.hideDelay != _hideTimer.delay) {
// log.info("startHideTimer(), using new delay " + _config.hideDelay);
_hideTimer.stop();
_hideTimer = new Timer(_config.hideDelay);
//_hideTimer = new Timer(_config.hideDelay);
_hideTimer.delay = _hideTimer.delay;
}
_hideTimer.addEventListener(TimerEvent.TIMER, hide);
//_hideTimer.addEventListener(TimerEvent.TIMER, hide);
_hideTimer.start();
}
private function stopHideTimer():void {
if (! _hideTimer) return;
_hideTimer.stop();
_hideTimer.reset();
_hideTimer.removeEventListener(TimerEvent.TIMER, hide);
_hideTimer = null;
}
......
......@@ -136,14 +136,14 @@ package org.flowplayer.controls.scrubber {
log.debug("stopTrickPlayTracking()");
if (_trickPlayTrackTimer) {
_trickPlayTrackTimer.stop();
_trickPlayTrackTimer.addEventListener(TimerEvent.TIMER, onTrickPlayProgress);
_trickPlayTrackTimer = null;
}
}
private function startTrickPlayTracking():void {
log.debug("startTrickPlayTracking()");
if (_trickPlayTrackTimer) {
_trickPlayTrackTimer.stop();
}
stopTrickPlayTracking();
_trickPlayTrackTimer = new Timer(200);
_trickPlayTrackTimer.addEventListener(TimerEvent.TIMER, onTrickPlayProgress);
_trickPlayTrackTimer.start();
......@@ -246,6 +246,7 @@ package org.flowplayer.controls.scrubber {
var time:Number = startTime > 0 ? startTime : status.time;
_startDetectTimer = new Timer(200);
//#163 set weak listener and clear the timer when done.
_startDetectTimer.addEventListener(TimerEvent.TIMER,
function(event:TimerEvent):void {
var currentTime:Number = _player.status.time;
......@@ -253,6 +254,7 @@ package org.flowplayer.controls.scrubber {
if (Math.abs(currentTime - time) > 0.2) {
_startDetectTimer.stop();
_startDetectTimer = null;
var endPos:Number = width - _dragger.width;
// log.debug("animation duration is " + clip.duration + " - "+ time + " * 1000");
// var duration:Number = (clip.duration - time) * 1000;
......@@ -269,7 +271,7 @@ package org.flowplayer.controls.scrubber {
return c * t / d + b;
});
}
});
}, false, 0, true);
log.debug("doStart(), starting timer");
_startDetectTimer.start();
}
......@@ -291,6 +293,8 @@ package org.flowplayer.controls.scrubber {
log.debug("stop()");
if (_startDetectTimer) {
_startDetectTimer.stop();
//#163 set weak listener and clear the timer when done.
_startDetectTimer = null;
}
animationEngine.cancel(_dragger);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment