Issue with addAsync
hi,
i have issue addasync handler function not invoked when event fired. not work use addasync in deeper function calls below code.
the player fire mediacomplete event correct handler never called. know has ideas of problem is?
here flow of code:
- play video
- let plays 10 seconds (wait none existing event)
- seek end of time elapse
- verify video 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") string;
assert.asserttrue("position should video's length.", pos.indexof(expectedpos) == 0);
var state:string = player.instance.callmethod("getstate") string;
assert.assertequals("video should stopped after seek beyond length.", playerstate.stopped, state);
}
private function errorvidseekbeyondlengthnotstop(param:object):void
{
fail("video not stopped after seek beyond length.");
}
thanks,
dina
i have issue addasync handler function not invoked when event fired. not work use addasync in deeper function calls below code.
the player fire mediacomplete event correct handler never called. know has ideas of problem is?
here flow of code:
- play video
- let plays 10 seconds (wait none existing event)
- seek end of time elapse
- verify video 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") string;
assert.asserttrue("position should video's length.", pos.indexof(expectedpos) == 0);
var state:string = player.instance.callmethod("getstate") string;
assert.assertequals("video should stopped after seek beyond length.", playerstate.stopped, state);
}
private function errorvidseekbeyondlengthnotstop(param:object):void
{
fail("video not stopped after seek beyond length.");
}
thanks,
dina
i suspect problem because verifyvidseekbeyondlength is<br />defined errorfunction addasync, once has triggered<br />flexunit assumes test has failed , doesn't expect any<br />further testing occur. result future events ignored<br />which why mediacomplete ignored. if instead define<br />and start own 10 second timer has it'<br />timerevent.timer_complete an addasync(verifyvidseekbeyondlength,<br />15000) handler work correctly.<br /><br />as side note, call in test to<br />player.instance.removeeventlistener(e.type, putvideoplayfor10secs);<br />isn't doing anything. need remove function returned<br />by addasync() call remove event listener was<br />registered.<br /><br />-- daniel r. <danielr@neophi.com> [http://danielr.neophi.com/]<br /><br />on wed, feb 11, 2009 @ 3:05 pm, dina <member@adobeforums.com> wrote:<br />> new discussion started dina in<br />><br />> flexunit development --<br />> issue addasync<br />><br />> hi,<br />><br />> have issue addasync handler function not invoked when<br />> event fired. not work use addasync in deeper function calls as<br />> below code.<br />><br />> player fire mediacomplete event correct handler never get<br />> called. know has ideas of problem is?<br />><br />> here flow of code:<br />> - play video<br />> - let plays 10 seconds (wait none existing event)<br />> - seek end of time elapse<br />> - verify video stopped playing
More discussions in FlexUnit Development
adobe
Comments
Post a Comment