Skip to main content
Known Participant
January 12, 2012
Question

How to get the number of viewers live stream?

  • January 12, 2012
  • 3 replies
  • 1831 views

Subj.

I want to know how many viewers watch stream at the moment. How to find this out?

    This topic has been closed for replies.

    3 replies

    Lokki7Author
    Known Participant
    January 14, 2012

    that's how I did it

    var nc_admin = new NetConnection;
    
    
    function timer1(){
        nc_admin.call("getLiveStreams", new onGetLiveStreams(), "live");
    }
     
    setInterval(timer1, 5000); 
    
    function onGetLiveStreams() {
        this.onResult = function(ans) {
         for (i = 0; i < ans.data.length; i++){ 
             nc_admin.call("getLiveStreamStats", new onGetLiveStreamStats(), "live" , ans.data);
         }
        }
    
    }
    
    function onGetLiveStreamStats(){
        this.onResult = function(info) {
         if(info.data.publisher && info.data.subscribers) {
             var so = SharedObject.get(info.data.publisher.name, false); 
             so.setProperty('viewers', info.data.subscribers.length);
         } 
        }
    }
    
    application.onAppStart = function(){
    
        trace("Starting...");    
        nc_admin.connect("rtmp://localhost:1111/admin", "fmsroot", "ljvedjls"); 
        
    }
    
    
    Participant
    June 26, 2012

    Hi, anyone can write a working example?
    - server-Side
    - client side
    The example above I have not worked.

    Lokki7Author
    Known Participant
    January 12, 2012

    Can I call getLiveStreamStats() on server side? Without NetConnection to localhost!

    Participant
    January 12, 2012

    If you have access to you FMS Admin Console you can simply look how much clients are connected to your application(s).

    If you need the current number of viewers on your client side you can store the connections into a shared object within your application.

    Lokki7Author
    Known Participant
    January 12, 2012

    FMS Admin Console shows all clients of the application. But there may be more than one stream.

    I need to know clients per stream