Question
Issue with addAsync
Hi,
I have an issue with addAsync that handler function is not invoked when event fired. It does not work as I use addAsync in deeper function calls as below code.
The player does fire MediaComplete event but correct handler never get called. Anyone know has ideas of what the problem is?
Here is the flow of the code:
- Play a video
- Let it plays for 10 seconds (wait for a none existing event)
- Seek to the end of time elapse
- Verify video is stopped playing
public function testVidSeekBeyondLength():void
{
var uuid:String = "7b992781-37f7-4abd-a948-f7d540237aa7";
Player.Instance.addEventListener(Events.VideoLoaded,
addAsync(putVideoPlayFor10Secs,
45000,
null,
null));
Player.Instance.callMethod("playId", uuid);
}
private function putVideoPlayFor10Secs(e:Event):void
{
Player.Instance.removeEventListener(e.type, putVideoPlayFor10Secs);
Player.Instance.addEventListener(Events.NotExist,
addAsync(neverInvoke,
10000,
null,
verifyVidSeekBeyondLength));
}
private function verifyVidSeekBeyondLength(e:Event):void
{
Player.Instance.removeEventListener(Events.NotExist, neverInvoke);
var length:Number = Player.Instance.videoWindow.Duration;
Player.Instance.addEventListener(Events.MediaComplete,
addAsync (verifyVidSeekBeyondLengthStop,
15000,
null,
errorVidSeekBeyondLengthNotStop));
Player.Instance.callMethod("seek", length);
}
private function verifyVidSeekBeyondLengthStop(e:Event):void
{
Player.Instance.removeEventListener(e.type, verifyVidSeekBeyondLengthStop);
var length:Number = Player.Instance.videoWindow.Duration;
var start:int = new int(length / 60);
var expectedPos:String = new String(start) + ":";
var pos:String = Player.Instance.callMethod("getPosition") as String;
Assert.assertTrue("Position should be the video's length.", pos.indexOf(expectedPos) == 0);
var state:String = Player.Instance.callMethod("getState") as String;
Assert.assertEquals("Video should be stopped after seek beyond its length.", PlayerState.Stopped, state);
}
private function errorVidSeekBeyondLengthNotStop(param:Object):void
{
fail("Video was not stopped after seek beyond its length.");
}
Thanks,
Dina
I have an issue with addAsync that handler function is not invoked when event fired. It does not work as I use addAsync in deeper function calls as below code.
The player does fire MediaComplete event but correct handler never get called. Anyone know has ideas of what the problem is?
Here is the flow of the code:
- Play a video
- Let it plays for 10 seconds (wait for a none existing event)
- Seek to the end of time elapse
- Verify video is stopped playing
public function testVidSeekBeyondLength():void
{
var uuid:String = "7b992781-37f7-4abd-a948-f7d540237aa7";
Player.Instance.addEventListener(Events.VideoLoaded,
addAsync(putVideoPlayFor10Secs,
45000,
null,
null));
Player.Instance.callMethod("playId", uuid);
}
private function putVideoPlayFor10Secs(e:Event):void
{
Player.Instance.removeEventListener(e.type, putVideoPlayFor10Secs);
Player.Instance.addEventListener(Events.NotExist,
addAsync(neverInvoke,
10000,
null,
verifyVidSeekBeyondLength));
}
private function verifyVidSeekBeyondLength(e:Event):void
{
Player.Instance.removeEventListener(Events.NotExist, neverInvoke);
var length:Number = Player.Instance.videoWindow.Duration;
Player.Instance.addEventListener(Events.MediaComplete,
addAsync (verifyVidSeekBeyondLengthStop,
15000,
null,
errorVidSeekBeyondLengthNotStop));
Player.Instance.callMethod("seek", length);
}
private function verifyVidSeekBeyondLengthStop(e:Event):void
{
Player.Instance.removeEventListener(e.type, verifyVidSeekBeyondLengthStop);
var length:Number = Player.Instance.videoWindow.Duration;
var start:int = new int(length / 60);
var expectedPos:String = new String(start) + ":";
var pos:String = Player.Instance.callMethod("getPosition") as String;
Assert.assertTrue("Position should be the video's length.", pos.indexOf(expectedPos) == 0);
var state:String = Player.Instance.callMethod("getState") as String;
Assert.assertEquals("Video should be stopped after seek beyond its length.", PlayerState.Stopped, state);
}
private function errorVidSeekBeyondLengthNotStop(param:Object):void
{
fail("Video was not stopped after seek beyond its length.");
}
Thanks,
Dina
