Commit 6609cde5 authored by Anssi Piirainen's avatar Anssi Piirainen
Browse files

Merge danielr-163 into dev

Conflicts:
	core/src/actionscript/org/flowplayer/view/Launcher.as
parents 90dc9e91 04ba4cea
...@@ -20,13 +20,14 @@ ...@@ -20,13 +20,14 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
package org.goasap.items { package org.goasap.items {
import flash.utils.getTimer;
import flash.utils.getTimer;
import org.goasap.GoEngine; import org.goasap.GoEngine;
import org.goasap.errors.EasingFormatError; import org.goasap.errors.EasingFormatError;
import org.goasap.events.GoEvent; import org.goasap.events.GoEvent;
import org.goasap.interfaces.IPlayable; 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 * Dispatched during an animation's first update after the delay
...@@ -262,13 +263,14 @@ package org.goasap.items { ...@@ -262,13 +263,14 @@ package org.goasap.items {
} }
public function set easing(type:Function):void { public function set easing(type:Function):void {
if (_state==STOPPED) { if (_state==STOPPED) {
try { //try {
if (type(1,1,1,1) is Number) { if (type(1,1,1,1) is Number) {
_easing = type; _easing = type;
return; return;
} }
} catch (e:Error) {} //} catch (e:Error) {}
throw new EasingFormatError(); //#163 don't throw an error just because.
//throw new EasingFormatError();
} }
} }
...@@ -496,18 +498,25 @@ package org.goasap.items { ...@@ -496,18 +498,25 @@ package org.goasap.items {
defaultDelay = 0; defaultDelay = 0;
if (isNaN(defaultDuration)) if (isNaN(defaultDuration))
defaultDuration = 1; defaultDuration = 1;
try { this.easing = defaultEasing; } /*try { this.easing = defaultEasing; }
catch (e1:EasingFormatError) { defaultEasing = easeOut; } catch (e1:EasingFormatError) { defaultEasing = easeOut; } */
//#163 set default easing
this.easing = easeOut;
// set params // set params
if (!isNaN(delay)) _delay = delay; if (!isNaN(delay)) _delay = delay;
else _delay = defaultDelay; else _delay = defaultDelay;
if (!isNaN(duration)) _duration = duration; if (!isNaN(duration)) _duration = duration;
else _duration = defaultDuration; else _duration = defaultDuration;
try { this.easing = easing; } /*try { this.easing = easing; }
catch (e2:EasingFormatError) { catch (e2:EasingFormatError) {
if (easing!=null) { throw e2; } // user passed invalid easing function if (easing!=null) { throw e2; } // user passed invalid easing function
this.easing = defaultEasing; 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 (extraEasingParams) _extraEaseParams = extraEasingParams;
if (useRelative) this.useRelative = true; if (useRelative) this.useRelative = true;
if (useRounding) this.useRounding = true; if (useRounding) this.useRounding = true;
......
...@@ -286,14 +286,18 @@ package org.flowplayer.view { ...@@ -286,14 +286,18 @@ package org.flowplayer.view {
private function startTimer():void { private function startTimer():void {
_hideTimer = new Timer(_model.displayTime * 1000, 1); _hideTimer = new Timer(_model.displayTime * 1000, 1);
_hideTimer.addEventListener(TimerEvent.TIMER_COMPLETE, _hideTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onHideComplete);
function(event:TimerEvent):void {
log.debug("display time complete");
hide(_model.fadeSpeed);
_hideTimer.stop();
});
_hideTimer.start(); _hideTimer.start();
} }
private function onHideComplete(event:TimerEvent):void
{
log.debug("display time complete");
hide(_model.fadeSpeed);
_hideTimer.reset();
_hideTimer.removeEventListener(TimerEvent.TIMER_COMPLETE, onHideComplete);
_hideTimer = null;
}
CONFIG::freeVersion CONFIG::freeVersion
public function setModel(model:Logo):void { public function setModel(model:Logo):void {
......
...@@ -481,7 +481,12 @@ package org.flowplayer.view { ...@@ -481,7 +481,12 @@ package org.flowplayer.view {
var time:Number = _player.status.time; var time:Number = _player.status.time;
if (_playDetectTimer) {
_playDetectTimer.reset();
_playDetectTimer = null;
}
_playDetectTimer = new Timer(200); _playDetectTimer = new Timer(200);
//#163 use weak reference event here
_playDetectTimer.addEventListener(TimerEvent.TIMER, _playDetectTimer.addEventListener(TimerEvent.TIMER,
function(event:TimerEvent):void { function(event:TimerEvent):void {
var currentTime:Number = _player.status.time; var currentTime:Number = _player.status.time;
...@@ -494,7 +499,7 @@ package org.flowplayer.view { ...@@ -494,7 +499,7 @@ package org.flowplayer.view {
} else { } else {
log.debug("not started yet, currentTime " + currentTime + ", time " + time); log.debug("not started yet, currentTime " + currentTime + ", time " + time);
} }
}); }, false, 0, true);
log.debug("doStart(), starting timer"); log.debug("doStart(), starting timer");
_playDetectTimer.start(); _playDetectTimer.start();
} }
......
...@@ -84,13 +84,20 @@ package org.flowplayer.controller { ...@@ -84,13 +84,20 @@ package org.flowplayer.controller {
private function createDurationTracker(clip:Clip):void { private function createDurationTracker(clip:Clip):void {
if (durationTracker) { if (durationTracker) {
durationTracker.stop(); clearDurationTracker();
} }
durationTracker = new PlayTimeTracker(clip, this); durationTracker = new PlayTimeTracker(clip, this);
durationTracker.addEventListener(TimerEvent.TIMER_COMPLETE, durationReached); durationTracker.addEventListener(TimerEvent.TIMER_COMPLETE, durationReached);
durationTracker.start(); durationTracker.start();
} }
private function clearDurationTracker():void
{
durationTracker.stop();
durationTracker.removeEventListener(TimerEvent.TIMER_COMPLETE, durationReached);
durationTracker = null;
}
public function get time():Number { public function get time():Number {
if (!durationTracker) return 0; if (!durationTracker) return 0;
var time:Number = durationTracker.time; var time:Number = durationTracker.time;
...@@ -166,8 +173,8 @@ package org.flowplayer.controller { ...@@ -166,8 +173,8 @@ package org.flowplayer.controller {
private function stop(event:ClipEvent, closeStream:Boolean, silent:Boolean = false):void { private function stop(event:ClipEvent, closeStream:Boolean, silent:Boolean = false):void {
log.debug("stop " + durationTracker); log.debug("stop " + durationTracker);
if (durationTracker) { if (durationTracker) {
durationTracker.stop();
durationTracker.time = 0; durationTracker.time = 0;
clearDurationTracker();
} }
doStop(silent ? null : event, closeStream); doStop(silent ? null : event, closeStream);
} }
......
...@@ -64,6 +64,7 @@ package org.flowplayer.controller { ...@@ -64,6 +64,7 @@ package org.flowplayer.controller {
log.debug("stop()"); log.debug("stop()");
if (_timer && _timer.running) { if (_timer && _timer.running) {
_timer.stop(); _timer.stop();
_timer.removeEventListener(TimerEvent.TIMER, onTimer);
} }
} }
......
...@@ -17,30 +17,30 @@ ...@@ -17,30 +17,30 @@
*/ */
package org.flowplayer.controller { package org.flowplayer.controller {
import flash.display.DisplayObject; import flash.display.DisplayObject;
import flash.errors.IOError; import flash.errors.IOError;
import flash.events.NetStatusEvent; import flash.events.NetStatusEvent;
import flash.events.TimerEvent; import flash.events.TimerEvent;
import flash.media.Video; import flash.media.Video;
import flash.net.NetConnection; import flash.net.NetConnection;
import flash.net.NetStream; import flash.net.NetStream;
import flash.utils.Dictionary; import flash.utils.Dictionary;
import flash.utils.Timer; import flash.utils.Timer;
import org.flowplayer.model.Clip; import org.flowplayer.model.Clip;
import org.flowplayer.model.ClipError; import org.flowplayer.model.ClipError;
import org.flowplayer.model.ClipEvent; import org.flowplayer.model.ClipEvent;
import org.flowplayer.model.ClipEventType; import org.flowplayer.model.ClipEventType;
import org.flowplayer.model.Playlist; import org.flowplayer.model.Playlist;
import org.flowplayer.model.PluginModel; import org.flowplayer.model.PluginModel;
import org.flowplayer.model.ProviderModel; import org.flowplayer.model.ProviderModel;
import org.flowplayer.util.Assert; import org.flowplayer.util.Assert;
import org.flowplayer.util.Log; import org.flowplayer.util.Log;
import org.flowplayer.view.Flowplayer; import org.flowplayer.view.Flowplayer;
CONFIG::FLASH_10_1 { CONFIG::FLASH_10_1 {
import org.flowplayer.view.StageVideoWrapper; import org.flowplayer.view.StageVideoWrapper;
} }
/** /**
* A StreamProvider that does it's job using the Flash's NetStream class. * A StreamProvider that does it's job using the Flash's NetStream class.
...@@ -117,7 +117,7 @@ CONFIG::FLASH_10_1 { ...@@ -117,7 +117,7 @@ CONFIG::FLASH_10_1 {
} }
private function _load(clip:Clip, pauseAfterStart:Boolean, attempts:int = 3):void { private function _load(clip:Clip, pauseAfterStart:Boolean, attempts:int = 3):void {
Assert.notNull(clip, "load(clip): clip cannot be null"); Assert.notNull(clip, "load(clip): clip cannot be null");
_paused = false; _paused = false;
_stopping = false; _stopping = false;
_attempts = attempts; _attempts = attempts;
...@@ -832,6 +832,13 @@ CONFIG::FLASH_10_1 { ...@@ -832,6 +832,13 @@ CONFIG::FLASH_10_1 {
if (_seekTarget < 0) return; if (_seekTarget < 0) return;
if (_seekTargetWaitTimer && _seekTargetWaitTimer.running) return; if (_seekTargetWaitTimer && _seekTargetWaitTimer.running) return;
log.debug("starting seek target wait timer"); log.debug("starting seek target wait timer");
if (_seekTargetWaitTimer) {
_seekTargetWaitTimer.reset();
_seekTargetWaitTimer.removeEventListener(TimerEvent.TIMER, onSeekTargetWait);
_seekTargetWaitTimer = null;
}
_seekTargetWaitTimer = new Timer(200); _seekTargetWaitTimer = new Timer(200);
_seekTargetWaitTimer.addEventListener(TimerEvent.TIMER, onSeekTargetWait); _seekTargetWaitTimer.addEventListener(TimerEvent.TIMER, onSeekTargetWait);
_seekTargetWaitTimer.start(); _seekTargetWaitTimer.start();
...@@ -840,7 +847,8 @@ CONFIG::FLASH_10_1 { ...@@ -840,7 +847,8 @@ CONFIG::FLASH_10_1 {
private function onSeekTargetWait(event:TimerEvent):void { private function onSeekTargetWait(event:TimerEvent):void {
//#104 if the updated time is a fraction less than the seek target time ie for HDS, use a bitwise rounding so the seek time can stop. //#104 if the updated time is a fraction less than the seek target time ie for HDS, use a bitwise rounding so the seek time can stop.
if ((time|0) >= (_seekTarget|0)) { if ((time|0) >= (_seekTarget|0)) {
_seekTargetWaitTimer.stop(); _seekTargetWaitTimer.reset();
_seekTargetWaitTimer.removeEventListener(TimerEvent.TIMER, onSeekTargetWait);
log.debug("dispatching onSeek"); log.debug("dispatching onSeek");
dispatchPlayEvent(ClipEventType.SEEK, _seekTarget); dispatchPlayEvent(ClipEventType.SEEK, _seekTarget);
_seekTarget = -1; _seekTarget = -1;
...@@ -876,12 +884,14 @@ CONFIG::FLASH_10_1 { ...@@ -876,12 +884,14 @@ CONFIG::FLASH_10_1 {
try { try {
netStream.close(); netStream.close();
_netStream.removeEventListener(NetStatusEvent.NET_STATUS, _onNetStatus);
_netStream = null; _netStream = null;
} catch (e:Error) { } catch (e:Error) {
} }
if (_connection) { if (_connection) {
_connection.close(); _connection.close();
_connection.removeEventListener(NetStatusEvent.NET_STATUS, _onNetStatus);
_connection = null; _connection = null;
} }
......
...@@ -90,10 +90,11 @@ package org.flowplayer.controller { ...@@ -90,10 +90,11 @@ package org.flowplayer.controller {
doConnect(_rtmpConnector, _proxyType, objectEncoding, connArgs); doConnect(_rtmpConnector, _proxyType, objectEncoding, connArgs);
// RTMPT connect is started after 250 ms // RTMPT connect is started after 250 ms
//#163 weak reference
var delay:Timer = new Timer(_failOverDelay, 1); var delay:Timer = new Timer(_failOverDelay, 1);
delay.addEventListener(TimerEvent.TIMER, function(event:TimerEvent):void { delay.addEventListener(TimerEvent.TIMER, function(event:TimerEvent):void {
doConnect(_rtmptConnector, _proxyType, objectEncoding, connArgs); doConnect(_rtmptConnector, _proxyType, objectEncoding, connArgs);
}); }, false, 0 , true);
delay.start(); delay.start();
} else { } else {
......
...@@ -57,7 +57,8 @@ package org.flowplayer.controller { ...@@ -57,7 +57,8 @@ package org.flowplayer.controller {
if (_connectionClient) { if (_connectionClient) {
_connection.client = _connectionClient; _connection.client = _connectionClient;
} }
_connection.addEventListener(NetStatusEvent.NET_STATUS, _onConnectionStatus); //#163 weak reference to listener
_connection.addEventListener(NetStatusEvent.NET_STATUS, _onConnectionStatus, false, 0 , true);
log.debug("netConnectionUrl is " + _url); log.debug("netConnectionUrl is " + _url);
if (connectionArgs && connectionArgs.length > 0) { if (connectionArgs && connectionArgs.length > 0) {
......
...@@ -329,7 +329,9 @@ package org.flowplayer.controller { ...@@ -329,7 +329,9 @@ package org.flowplayer.controller {
} }
private function replacePlaylistAndPlay(clips:Object):void { private function replacePlaylistAndPlay(clips:Object):void {
stop();
//#163 stop the connection and stream
_state.stop(true, true);
if (clips is Clip) { if (clips is Clip) {
_playList.replaceClips(clips as Clip); _playList.replaceClips(clips as Clip);
} else { } else {
......
...@@ -28,7 +28,6 @@ package org.flowplayer.controller { ...@@ -28,7 +28,6 @@ package org.flowplayer.controller {
private var _onLastSecondDispatched:Boolean; private var _onLastSecondDispatched:Boolean;
private var _controller:MediaController; private var _controller:MediaController;
private var _endDetectTimer:Timer; private var _endDetectTimer:Timer;
private var _wasPaused:Boolean = false;
private var _lastTimeDetected:Number; private var _lastTimeDetected:Number;
public function PlayTimeTracker(clip:Clip, controller:MediaController) { public function PlayTimeTracker(clip:Clip, controller:MediaController) {
...@@ -52,7 +51,9 @@ package org.flowplayer.controller { ...@@ -52,7 +51,9 @@ package org.flowplayer.controller {
public function stop():void { public function stop():void {
if (!_progressTimer) return; if (!_progressTimer) return;
_storedTime = time; _storedTime = time;
_progressTimer.stop(); _progressTimer.reset();
_progressTimer.removeEventListener(TimerEvent.TIMER, checkProgress);
_progressTimer = null;
log.debug("stopped at time " + _storedTime); log.debug("stopped at time " + _storedTime);
} }
...@@ -129,27 +130,29 @@ package org.flowplayer.controller { ...@@ -129,27 +130,29 @@ package org.flowplayer.controller {
private function startEndTimer(clip:Clip):void { private function startEndTimer(clip:Clip):void {
bindEndListeners(); bindEndListeners();
_endDetectTimer.addEventListener(TimerEvent.TIMER, _endDetectTimer.addEventListener(TimerEvent.TIMER, onEndTime);
function(event:TimerEvent):void {
log.debug("last time detected == " + _lastTimeDetected);
if(time == _lastTimeDetected && _endDetectTimer.running || durationReached) {
log.debug("clip has reached his end, timer stopped");
_endDetectTimer.reset();
completelyPlayed();
}
_lastTimeDetected = time;
}
);
log.debug("starting end detect timer"); log.debug("starting end detect timer");
_endDetectTimer.start(); _endDetectTimer.start();
} }
private function onEndTime(event:TimerEvent):void
{
log.debug("last time detected == " + _lastTimeDetected);
if(time == _lastTimeDetected && _endDetectTimer.running || durationReached) {
log.debug("clip has reached his end, timer stopped");
_endDetectTimer.reset();
completelyPlayed();
}
_lastTimeDetected = time;
}
private function completelyPlayed():void { private function completelyPlayed():void {
if(_endDetectTimer.running) { if(_endDetectTimer.running) {
unbindEndListeners(); unbindEndListeners();
_endDetectTimer.reset(); _endDetectTimer.reset();
_endDetectTimer.removeEventListener(TimerEvent.TIMER, onEndTime);
_endDetectTimer = null; _endDetectTimer = null;
} }
...@@ -182,6 +185,8 @@ package org.flowplayer.controller { ...@@ -182,6 +185,8 @@ package org.flowplayer.controller {
log.debug("this cuepoint already fired"); log.debug("this cuepoint already fired");
} }
} }
points = null;
} }
private function collectCuepoints(clip:Clip, timeRounded:Number):Array { private function collectCuepoints(clip:Clip, timeRounded:Number):Array {
......
...@@ -104,6 +104,7 @@ package org.flowplayer.controller { ...@@ -104,6 +104,7 @@ package org.flowplayer.controller {
dispatchEvent(PlayerEvent.volume(this.volume)); dispatchEvent(PlayerEvent.volume(this.volume));
if (!_storeDelayTimer.running) { if (!_storeDelayTimer.running) {
log.info("starting delay timer"); log.info("starting delay timer");
_storeDelayTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerDelayComplete);
_storeDelayTimer.start(); _storeDelayTimer.start();
} }
} }
...@@ -123,6 +124,7 @@ package org.flowplayer.controller { ...@@ -123,6 +124,7 @@ package org.flowplayer.controller {
private function storeVolume(muted:Boolean = false):void { private function storeVolume(muted:Boolean = false):void {
log.info("persisting volume level"); log.info("persisting volume level");
_storeDelayTimer.stop(); _storeDelayTimer.stop();
_storeDelayTimer.removeEventListener(TimerEvent.TIMER_COMPLETE, onTimerDelayComplete);
_storedVolume.volume = _soundTransform.volume; _storedVolume.volume = _soundTransform.volume;
_storedVolume.muted = muted; _storedVolume.muted = muted;
_storedVolume.persist(); _storedVolume.persist();
......
...@@ -23,8 +23,8 @@ package org.flowplayer.model { ...@@ -23,8 +23,8 @@ package org.flowplayer.model {
* @author api * @author api
*/ */
public class ClipEventSupport extends ClipEventDispatcher { public class ClipEventSupport extends ClipEventDispatcher {
private var _clips:Array; protected var _clips:Array;
private var _commonClip:Clip; protected var _commonClip:Clip;
public function ClipEventSupport(commonClip:Clip, clips:Array = null) { public function ClipEventSupport(commonClip:Clip, clips:Array = null) {
_commonClip = commonClip; _commonClip = commonClip;
......
...@@ -17,8 +17,11 @@ ...@@ -17,8 +17,11 @@
*/ */
package org.flowplayer.model { package org.flowplayer.model {
import org.flowplayer.flow_internal; import org.flowplayer.flow_internal;
use namespace flow_internal; use namespace flow_internal;
/** /**
* @author anssi * @author anssi
...@@ -27,28 +30,28 @@ package org.flowplayer.model { ...@@ -27,28 +30,28 @@ package org.flowplayer.model {
private var _currentPos:Number; private var _currentPos:Number;
private var _inStreamClip:Clip; private var _inStreamClip:Clip;
private var _commonClip:Clip;
private var _clips:Array;