Three things in order to run video flv:

1. Create blank new flash file. Open library, add "New video" object to library, then add it to stage with the instance name "my_video".
2. Create new layer with a multy-line input text field w/ a border that lies above the "blank video object". The instance name of the txt object must be: "status_txt"
3. Add script written below to the first frame of the flash movie. Save flash movie with the name you want + put following FLV file (videoFile.flv) in the same directory where you're going to execute SWF for streaming.
****************************Code************************************
status_txt.text += "initialize streaming engine" + newline;
// Create a NetConnection object
var netConn:NetConnection = new NetConnection();
status_txt.text += "creating net connection object..." + newline;
// Create a local streaming connection
netConn.connect(null);
var netStreamStatus = "";
var videoStatus = "loading";
// Create a NetStream object and define an onStatus() function
var netStream:NetStream = new NetStream(netConn);
//status_txt.text += "creating net stream object..." + newline;
netStream.onStatus = function(infoObject) {
//var lvl = infoObject.level;
//var code = infoObject.code;
//if (infoObject.code == "NetStream.Buffer.Full") {
//status_txt.text += newline + "Status (NetStream)" + newline;
//} else {
//status_txt.text += "Status (NetStream)" + newline;
//}
//status_txt.text += "Level: " + lvl + newline;
//status_txt.text += "Code: " + code + newline;
netStreamStatus = infoObject.code;
};
// Attach the NetStream video feed to the Video object
my_video.attachVideo(netStream);
//status_txt.text += "attach net streaming video" + newline;
// Set the buffer time
netStream.setBufferTime(10);
//status_txt.text += "set buffer time" + newline;
// Begin playing the FLV file
netStream.play("videoFile.flv");

//status_txt.text += "start streaming play" + newline;
this.onEnterFrame = function() {
if (netStreamStatus == "NetStream.Play.Start") {
var pos = status_txt.text.indexOf("buffering: ");
if(pos>-1) {
status_txt.replaceText(pos, status_txt.length, "buffering: " + netStream.bytesLoaded + " bytes loaded");
videoStatus = "buffering";
} else {
status_txt.text += "buffering: " + netStream.bytesLoaded + " bytes loaded "+ newline;
videoStatus = "buffering";
}
} else if (netStreamStatus == "NetStream.Buffer.Full") {
if(videoStatus == "buffering") {
status_txt.text += newline + "buffer loaded..." + newline + "playing movie" + newline;
videoStatus = "playing";
//status_txt.text += "video stat: " + videoStatus + newline;
}
} else if (netStreamStatus == "NetStream.Play.Stop") {
if(videoStatus == "playing") {
status_txt.text += "movie stopped" + newline;
videoStatus = "stopped";
//status_txt.text += "video stat: " + videoStatus + newline;
}
} else if (netStreamStatus == "NetStream.Buffer.Empty") {
if(videoStatus == "stopped") {
status_txt.text += "buffer empty..." + newline;
videoStatus = "empty";
//status_txt.text += "video stat: " + videoStatus + newline;
}
}
}

Nhận xét

Bài đăng phổ biến từ blog này

Ký tự viết tắt trong chat & email

dung lượng RAM lớn nhất mà HĐH cấu trúc 32-bit nhận được

Ubuntu LAMP Server