This video will show you how to play a streaming flv video file from a mobile device.
This is done using Flash and its Mobile Flash player (FlashLite 3.0)
Note: I couldn't run da app i created while doing the presentation becos i had mistakenly put a
fscommand2("fullscreen",true);
in the 1st frame, (silly me....)
I hope you have a basic knowledge of Flash and action scripting.
Please Comment and Rate the video.
Below is the code i used in frame25.
//Start code
stop();
fscommand2("SetSoftKeys", "Home","Pause");
//Variable to check if the video is being played.
var isPlaying:Boolean;
//create NetConnection and NetStream
var nc:NetConnection = new NetConnection();
var ns:NetStream;
nc.onStatus = function(info)
{
if(info.code == "NetConnection.Connect.Success")
{
ns = new NetStream(nc); //Here the 'VideoPlayer' if the Instance Name of the Video i dragged from the Library
VideoPlayer.attachVideo(ns); //you can pass a URL here too...
ns.play("Stealth.flv");
isPlaying = true;
txtRight.text = "Pause"
}
}
nc.connect(null);
ns.onStatus = function(info){ if(info.code == "NetStream.Play.Stop"){ isPlaying = false; txtRight.text = "Play"; }
};
Key.removeListener (myListener);
var myListener:Object = new Object ();
myListener.onKeyDown = function () { var keyCode = Key.getCode (); // Run this code if the user presses the left soft key. if (keyCode == ExtendedKey.SOFT1) { // Close the video. ns.close();
isPlaying = false; // Go to the home screen. gotoAndPlay (1); } // Run this code if the user presses the right soft key else if (keyCode == ExtendedKey.SOFT2) { // If the video is playing, run this code if (isPlaying){ // Pause or restart the video (this method does both). ns.pause(); // Switch the label text. if (txtRight.text == "Play"){ txtRight.text = "Pause"; } else if (txtRight.text == "Pause"){ txtRight.text = "Play"; } // If the video has finished playing, run this code. } else { // Replay the video. ns.play("Stealth.flv"); txtRight.text = "Pause"; isPlaying = true; } }
};
Key.addListener (myListener);
//Code end
thanx for the help brother
prince0hasa 3 years ago