About the release of the data stream on the FMS Server

Source: Internet
Author: User

I have read many posts on the Internet asking me how to broadcast streams on the FMS server and listen on the client.

Main. ASC:

AsCode

  1. VaR isplay = false;
  2. Application. onconnect =Function (client ){
  3. Application. acceptconnection (client );
  4. Trace ("It was connected !!");
  5. Client. playstream =Function (){
  6. VaR NS = stream. Get ("37studio ");
  7. If (NS ){
  8. If (! Isplay ){
  9. NS. Play ("Stream/test ");
  10. NS. Record ();
  11. Isplay =True;
  12. Return 0;
  13. }Else {
  14. Return stream. Length ("37studio ");
  15. }
  16. }
  17. }
  18. }

Client. fla:

As code

  1. Import flash. display. Sprite;
  2. Import flash. Events. netstatusevent;
  3. Import flash. Events. securityerrorevent;
  4. Import flash. Media. video;
  5. Import flash.net. netconnection;
  6. Import flash.net. netstream;
  7. Import flash. Events. event;
  8. Import flash.net. responder;
  9. Import flash.net. objectencoding;
  10. VaR videourl: String = "stream/test ";
  11. VaR connection: netconnection;
  12. VaR stream: netstream;
  13. Connection =New netconnection ();
  14. Connection. objectencoding = objectencoding. amf0;
  15. Connection. addeventlistener (netstatusevent. net_status, netstatushandler );
  16. Connection. addeventlistener (securityerrorevent. security_error, securityerrorhandler );
  17. Connection. Connect ("Rtmp: // localhost/serverpublih ");
  18. Function netstatushandler (Event: netstatusevent): void {
  19. Switch (event.info. Code ){
  20. Case "netconnection. Connect. Success ":
  21. Trace ("Connect success !!!");
  22. Connectstream ();
  23. Break;
  24. Case "netstream. Play. streamnotfound ":
  25. Trace ("Stream not found:" + videourl );
  26. Break;
  27. }
  28. }
  29. Function securityerrorhandler (Event: securityerrorevent): void {
  30. Trace ("Securityerrorhandler:" + Event );
  31. }
  32. Function connectstream (): void {
  33. Stream =New netstream (connection );
  34. Stream. addeventlistener (netstatusevent. net_status, netstatushandler );
  35. VaR video: Video = new video ();
  36. Video. attachnetstream (Stream );
  37. Addchild (video );
  38. Connection. Call ("Playstream", new Responder (onresult ));
  39. }
  40. Function onresult (para: *): void {
  41. Trace ("Para:" + para );
  42. Stream. Play ("37studio ");
  43. Stream. Seek (para );
  44. Return;
  45. }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.