1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
package
{
import flash.display.Sprite;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.media.Video;
import flash.events.NetStatusEvent;
public class TimeCodeTest extends Sprite
{
private var nc:NetConnection;
private var ns:NetStream;
public function TimeCodeTest()
{
nc=new NetConnection();
nc.client = this;
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
nc.connect("rtmp://10.1.80.156/myLiveApp/instance1/");
}
public function netStatusHandler(event:NetStatusEvent):void
{
switch (event.info.code)
{
case "NetConnection.Connect.Success":
trace("Connected!");
var clientObj:Object=new Object();
clientObj.onFI=onFIHandler;
ns=new NetStream(nc);
ns.client=clientObj;
var video:Video = new Video();
video.attachNetStream(ns);
ns.play("livestream"); // "livestream" is the name of the live stream you published
addChild(video);
break;
default:
break;
}
}
public function onBWDone():void
{
}
// define onFIHandler
public function onFIHandler(infoObj:Object):void
{
trace("FI works!!!");
trace("system time: " + infoObj.st);
}
}
} |
Partager