I have just come across a few issues whilst building a video player that plays streaming video from a Flash Media Server.
I thought I had everything set up fine but then when I tested I got the following error message …
ReferenceError: Error #1069: Property onBWDone not found on flash.net.NetConnection and there is no default value.
So to resolve this you need to set the client property of the netConnection instance to the object on which callback methods should be invoked. For example …
netConnection.client = this;
and then you need to have an empty public method called onBWDone, like this …
I then discovered that the netConnection with the server was being closed after 5 minutes of inactivity (e.g. pause the video and leave it for 5 minutes). What you need to do in this case is listen for the ‘NetConnection.Connect.IdleTimeOut’ NetStatusEvent, and gracefully close the netStream yourself. For example …
privatefunction onNetConnection_NET_STATUS(event:NetStatusEvent):void { switch(event.info.code){ case"NetConnection.Connect.IdleTimeOut": netStream.close(); netStream = null; // Display a still image or message to the user ro something break; } }
Have just built a video player that allowed the user to switch to FullScreen mode and toggle the play/pause state using the SPACE key on their keyboard. However, I found that everytime the Flash movie entered FullScreen mode the playing video would pause and visa-versa.
I then discovered that the Flash Player was dispatching a KEY_DOWN event when entering FullScreen mode. More specifically, the keyCode == 32, which corresponds to the spacebar on your keyboard.
The workaround is to temporarily remove the KEY_DOWN event listener, and add it again with a slight delay once the FULL_SCREEN event has been dispatched. You could create the delay by using either a Timer, an ENTER_FRAME event or the setTimeout method. In TyZ’s example he used an ENTER_FRAME event, in my example below I use an instance of the Timer class.
It allows you to embed Flash videos from sites like YouTube and Google Video in to your WordPress blog easily, and the resulting HTML code will be XHTML compliant.The syntax is as follows …