Adobe Air Crash when try to load video
Hi,
Recently, I am trying to do an very simple application using Adobe Air that plays video when certain key pressed on keyboard. However, the adobe air crash frequently when it try to load the video. The problem seems to be Adobe Air/ Flash player bug, because when I tried to do the debug, the debug launcher crash. I have tried with both f4v and mp4 format, but the situation is still the same.
I am using up to date Flash builder 4.5 and Adobe Air 2.7.1. Tested on both WinXP and Win7 Home Premium 32bit. Hopes to get your respond as soon as possible. If the problem cannot be solved soon, maybe I have to search for alternative solution to do the project. Thanks.
Here is my working code:
Display Window:
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" width="640" height="360" showStatusBar="false" applicationComplete="initConn()">
<fx:Script>
<![CDATA[
import flash.utils.setTimeout;
import mx.events.FlexEvent;
private var SWFconn:LocalConnection;
private var delay:Number = 300;
private var intervalId:uint;
protected var nWin:videoscreen = new videoscreen();
private var playing:Number = 0;
protected function initConn():void{
stage.addEventListener(KeyboardEvent.KEY_DOWN, handleKeyDown);
SWFconn = new LocalConnection();
nWin.width = 500;
nWin.height = 400;
nWin.open();
}
public function handleKeyDown(event:KeyboardEvent) :void
{
if(event.keyCode==13){
stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
nWin.fullscreen();
}else if(event.keyCode==27){
stage.displayState = StageDisplayState.NORMAL;
nWin.normalscreen();
}else{
if((playing==0)&&(((event.keyCode>=48)&&(event.keyCode<=57))||((event.keyCode>=65)&&(event.keyCode<=67)))){
playing=1;
SWFconn.send("swfConnection", "reset");
clearTimeout(intervalId);
SWFconn.send("swfConnection", "select", String.fromCharCode(event.charCode));
intervalId = setTimeout(sendLock,delay, String.fromCharCode(event.charCode));
}
}
}
private function sendLock(msg:String):void{
SWFconn.send("swfConnection", "lock", msg);
playing=1;
nWin.player.source = msg+".f4v";
nWin.player.play();
}
private function reset():void{
SWFconn.send("swfConnection", "reset");
}
public function playFinished():void{
reset();
playing =0;
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<mx:SWFLoader left="0" right="0" top="0" bottom="0" source="content.swf"/>
</s:WindowedApplication>
Video Window:
<?xml version="1.0" encoding="utf-8"?>
<s:Window xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300" showStatusBar="false">
<fx:Script>
<![CDATA[
import mx.core.FlexGlobals;
import org.osmf.events.TimeEvent;
protected function CallBack(event:TimeEvent):void
{
// TODO Auto-generated method stub
player.source="";
FlexGlobals.topLevelApplication.playFinished();
}
public function fullscreen():void
{
stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
}
public function normalscreen():void
{
stage.displayState = StageDisplayState.NORMAL;
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:VideoDisplay id="player" left="0" right="0" top="0" bottom="0" complete="CallBack(event)"/>
</s:Window>
