Skip to main content
NBauland
Participant
August 26, 2010
Answered

Authentication with FLVPlayback

  • August 26, 2010
  • 1 reply
  • 905 views

I'm beginner with FMS and AS3, so my question may appear stupid !

My application is based on vod. I don't want all people can access my videos. I try to developp an application where client must provided login/password to access these videos.

I have successed to send login/pw by put these code on swf client:

nc=new NetConnection();

nc.addEventListener(NetStatusEvent.NET_STATUS,netStatusHandler);
nc.connect("rtmp://address/vod/sample.flv","login","password");

In my server application, I've put these lines:

application.onConnect = function( p_client, p_User, p_Password ){
if((p_User != "login") || (p_Password!="password")){
  trace("Authentication failed.");
  return false;
}
this.acceptConnection(p_client);
}

When I look at Admin console, I see it works.

What I want to do now, is put a FLVplayback control in my client file to see the video based on these connection: here I'm lost. How can I pass my nc connection object to my FLVplayback control ? I hope my explanation wasn't confused.

Thanks in any help,

N. Bauland

    This topic has been closed for replies.
    Correct answer amit_kr

    I think you just need to access the place in fl package of flvplayback component where the connect method is getting called. You can get the fl packege at "C:\Program Files\Adobe\Adobe Flash CS4\Common\Configuration\Component Source\ActionScript 3.0\FLVPlayback" and just pass your extra two arguments ie "login" and "password" in connect method.

    Go to fl\video\NCManager.as file and check for the below method:

    flvplayback_internal function nextConnect(e:TimerEvent=null):void {
       var protocol:String;
       var port:String;
       if (_connTypeCounter == 0) {
        protocol = _protocol;
        port = _portNumber;
       } else {
        port = null;
        if (_protocol == "rtmp:/") {
         protocol = "rtmpt:/"
        } else if (_protocol == "rtmpe:/") {
         protocol = "rtmpte:/"
        } else {
         _tryNC.pop();
         return;
        }
       }
       var xnURL:String = protocol + ((_serverName == null) ? "" : "/" + _serverName + ((port == null) ? "" : (":" + port)) + "/") + ((_wrappedURL == null) ? "" : _wrappedURL + "/") + _appName + ((_queryString == null) ? "" : "?"+_queryString);
       _tryNC[_connTypeCounter].client.pending = true;
       _tryNC[_connTypeCounter].connect( xnURL, _autoSenseBW);
       if (_connTypeCounter < (_tryNC.length-1)) {
        _connTypeCounter++;
        _tryNCTimer.reset();
        _tryNCTimer.start();
       }
      }

    So, you can see connect method in bold is getting called here and xnURL is the url which you pass in the properties panel and source parameter of FLVPlayback component.

    You need to change the bold line as   _tryNC[_connTypeCounter].connect( xnURL, _autoSenseBW,"login","password");

    Hope this helps.

    Regards,

    Amit

    1 reply

    amit_krCorrect answer
    Adobe Employee
    August 27, 2010

    I think you just need to access the place in fl package of flvplayback component where the connect method is getting called. You can get the fl packege at "C:\Program Files\Adobe\Adobe Flash CS4\Common\Configuration\Component Source\ActionScript 3.0\FLVPlayback" and just pass your extra two arguments ie "login" and "password" in connect method.

    Go to fl\video\NCManager.as file and check for the below method:

    flvplayback_internal function nextConnect(e:TimerEvent=null):void {
       var protocol:String;
       var port:String;
       if (_connTypeCounter == 0) {
        protocol = _protocol;
        port = _portNumber;
       } else {
        port = null;
        if (_protocol == "rtmp:/") {
         protocol = "rtmpt:/"
        } else if (_protocol == "rtmpe:/") {
         protocol = "rtmpte:/"
        } else {
         _tryNC.pop();
         return;
        }
       }
       var xnURL:String = protocol + ((_serverName == null) ? "" : "/" + _serverName + ((port == null) ? "" : (":" + port)) + "/") + ((_wrappedURL == null) ? "" : _wrappedURL + "/") + _appName + ((_queryString == null) ? "" : "?"+_queryString);
       _tryNC[_connTypeCounter].client.pending = true;
       _tryNC[_connTypeCounter].connect( xnURL, _autoSenseBW);
       if (_connTypeCounter < (_tryNC.length-1)) {
        _connTypeCounter++;
        _tryNCTimer.reset();
        _tryNCTimer.start();
       }
      }

    So, you can see connect method in bold is getting called here and xnURL is the url which you pass in the properties panel and source parameter of FLVPlayback component.

    You need to change the bold line as   _tryNC[_connTypeCounter].connect( xnURL, _autoSenseBW,"login","password");

    Hope this helps.

    Regards,

    Amit

    NBauland
    NBaulandAuthor
    Participant
    August 27, 2010

    As I previously said, I'm beginner,  and I didn't even know that we can access source code of component !

    You have answered my question and you permit me to discover a very useful possibilities.

    Thank you very very much.