Skip to main content
March 7, 2011
Question

Simple HTML example on how to display a live stream?

  • March 7, 2011
  • 1 reply
  • 1157 views

Hi all

Is there anyone who has a HTML example (or can give an URL with a page) that has the Adobe Flash player displaying a live stream (and not a file)?

There is one in the installation under "Flash Media Server Start Screen" but it was too complex for me to understand. I just need a simple example on how to display a live flash stream in Adobes own web player.

Thank you very much 🙂

    This topic has been closed for replies.

    1 reply

    Participating Frequently
    March 8, 2011

    Hi,

    Here is the html code.

    <html>
    <head>
    <title>Flash Media Player</title>
    </head>

    <object width="550" height="400">
    <param name="movie" value="player.swf">
    <embed src="somefilename.swf" width="550" height="400">
    </embed>
    </object>

    </body>
    </html>

    And here is the action script code of player.swf.

    import flash.net.NetConnection;
    import flash.events.NetStatusEvent;
    import flash.net.NetStream;
    import flash.media.Video;
    import flash.events.MouseEvent;
    import flash.media.Camera;

    startBtn.addEventListener(MouseEvent.CLICK,mouseHandler);

    var nc:NetConnection;
    var ns:NetStream;
    var vid:Video;
    var cam:Camera=Camera.getCamera();

    function mouseHandler(evt:MouseEvent){
        nc=new NetConnection();
        nc.addEventListener(NetStatusEvent.NET_STATUS,statusHandler);
        nc.connect("rtmp://localhost/sample");
    }

    function statusHandler(evt:NetStatusEvent){
        trace(evt.info.code);
        if(evt.info.code=="NetConnection.Connect.Success"){
            ns=new NetStream(nc);
            ns.addEventListener(NetStatusEvent.NET_STATUS,streamHandler);
            ns.play("LiveStream");
            vid=new Video();
            vid.attachNetStream(ns);
            vid.height=400;
            vid.width=600;
            addChild(vid);
        }
    }

    function streamHandler(evt:NetStatusEvent){
        trace(evt.info.code);
    }

    Please do the following before using the actionscript code:

    Add a button called start in fla and keep its instance name startBtn.

    create an application called sample in FMS and publish a live stream called "LiveStream".