To realize the playback of media streaming files is very simple, as long as in the FMS server to provide good streaming media files, flash client through netconnection connected to the FMS server, and then through the NetStream loading on OK. about how to connect FMS in the first two of this series has been introduced in detail, first of all in FMS to establish a good server application and deployment of media files, as shown below:
Here is the streaming media file playback sample program developed in Flash:
1 import flash.display.*;
2 import flash.events.*;
3 import flash.net.*;
4
5 var nc:NetConnection = new NetConnection();
6 var ns:NetStream;
7 var video:Video;
8
9 nc.connect("rtmp://localhost/PlayStreams");
10 nc.addEventListener(NetStatusEvent.NET_STATUS,onStatusHandler);
11
12 function onStatusHandler(evt:NetStatusEvent):void
13 {
14 trace(evt.info.code);
15 if(evt.info.code=="NetConnection.Connect.Success")
16 {
17 ns=new NetStream(nc);
18 ns.addEventListener(NetStatusEvent.NET_STATUS,onStatusHandler);
19 ns.client=new CustomClient();
20 video=new Video();
21 video.attachNetStream(ns);
22 ns.play("2009031301",0);
23 addChild(video);
24 }
25 }