• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Appendix: IV Appendixes: Quick Reference... > Subscribe to a Live or Recorded Stre...

Subscribe to a Live or Recorded Stream

The script in Listing E.4 subscribes to, or receives, a live or prerecorded video (FLV) stream that is available within the application instance's streams folder.

Listing E.4. Flash ActionScript for Subscribing to or Receiving a Video Stream

nc = new NetConnection();
nc.onStatus = function(info) {
      trace(“LEVEL: “+info.level+”  CODE: “+info.code);
      if (info.code == “NetConnection.Connect.Success”) {
            // Call a function to setup the NetStream Subscription
            startStreamSubscribe();
      }
};
startStreamSubscribe = function () {
      // that exists on the Flash Stage.
      // attach a NetStream to the variable, sub_ns
      sub_ns = new NetStream(nc);
      // attach the Subscription source to a Video Object on the stage
      my_video.attachVideo(sub_ns);
      // Start the stream, "serverStream", (-2) if the live source is not available,
      // look for a recored stream of the same name.  (-1)Play until the stream is over
      sub_ns.play("serverStream", -2, -1);
};
nc.connect("rtmp://localhost/myApplication/myInstance", "Tracey Davis", "Bert");


					  


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint