0 Replies Latest reply on Aug 12, 2009 6:26 AM by sudheerTele

    How to play and stop flv files through NetStream in AIR Application

    sudheerTele

      Hi,

       

      In a folder I have 'n' number of flv file, which are DRM protected. when the user try to play those files for the first time through my AIR application, it will prompt for username and password and gets the license/voucher from the server and store it in AIR Runtime. so that from the next time onwords it won't prompt for username and password as because it already has license/voucher.

       

           My problem is assume there are 500 files, such that for each file the user has to enter his credentials[username and password]. which is a stupid thing. I want to avoid this process by implementing this process internally/programetically. By playing/accessing each file through netstream from the folder and setDRMAuthenticationCredentials for that file and stop the stream. Here I am able to play each file but I am failed to stop it. I mean to say I will get the license for all the flv files internally[while loading my AIR application], such that user should not be interrupted for his credentials for each file.He should play as if he is accessing/playing a non-DRM protected file. I will be very thank full if any one help me out in this.

       

       

      public function init():void {

            connectStream();
            getLicenseForAllFiles();
            videoStream.addEventListener(DRMAuthenticateEvent.DRM_AUTHENTICATE, drmAuthenticateEventHandler);
            ppt_videoStream.addEventListener(DRMAuthenticateEvent.DRM_AUTHENTICATE, ppt_drmAuthenticateEventHandler);

      }

       

       

              private function getFilesRecursive(rootFolderPath:String):void {
                  //the current folder object
                  var currentFolder:File = new File(rootFolderPath);
                 
                  //the current folder's file listing
                  var files:Array = currentFolder.getDirectoryListing();
                 
                  //iterate and put files in the result and process the sub folders recursively
                  for (var f = 0; f < files.length; f++) {
                      if (files[f].isDirectory) {
                          if (files[f].name !="." && files[f].name !="..") {
                              //it's a directory
                              getFilesRecursive(files[f].nativePath);
                          }
                      } else {
                          //it's a file
                          fileList.push(files[f].nativePath);
                          //Alert.show(""+files[0].nativePath);
                          var fileName:String = files[f].name;
                          if(fileName.indexOf("PPT_")!=-1){
                              ppt_videoStream.play(files[f].nativePath);
                              ppt_videoStream.pause();
                          }
                          videoStream.play(files[f].nativePath);
                          videoStream.pause();
                      }
                  }
              }

       

       

                  private function connectStream():void {
                      videoConnection = new NetConnection();
                      videoConnection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
                      videoConnection.connect(null);
                     
                      ppt_videoConnection = new NetConnection();
                      ppt_videoConnection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
                      ppt_videoConnection.connect(null);
                     
                      videoStream = new NetStream(videoConnection);
                      videoStream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
                      video.attachNetStream(videoStream);

       

                      ppt_videoStream = new NetStream(ppt_videoConnection);
                      ppt_videoStream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
                      ppt_video.attachNetStream(ppt_videoStream);
                  }

       

               private function netStatusHandler(event:NetStatusEvent):void {
                  switch (event.info.code) {
                      case "NetConnection.Connect.Success":
                          //connectStream();
                          break;
                      case "NetStream.Play.StreamNotFound":
                          trace("Unable to locate video: " + videoURL);
                          break;
                  }
              }

       

                  private function drmAuthenticateEventHandler(event:DRMAuthenticateEvent):void {
                      videoStream.setDRMAuthenticationCredentials("adobe", "adobe", "drm");

                  }

       

                  private function ppt_drmAuthenticateEventHandler(event:DRMAuthenticateEvent):void {
                      ppt_videoStream.setDRMAuthenticationCredentials("adobe", "adobe", "drm");

                  }

       

       

      Thanks

       

      Sudheer Puppala