4 Replies Latest reply on Mar 11, 2010 9:39 PM by Arun Lal

    How to play video repeatedly and with no audio

    roshni79

      Hello all,

       

      I use the following code to play video in Flex:

      public function startPlayback(event:CairngormEvent) : void

                {

           if (model.nsDemoRemotePlay != null )

                          {

                /**

                                     * Stop and close previous NetStream.

                                     */

                                    var demoStopStreamEvent :VCDemoStopStreamEvent = new VCDemoStopStreamEvent();

                                    CairngormEventDispatcher.getInstance().dispatchEvent(demoStopStreamEvent);

                          }

                          nc.connect(null);

                          /**

                           * Setup NetStream for playback.

                           */

                          model.nsDemoRemotePlay = new NetStream(nc);

                     

                          model. nsDemoRemotePlay.receiveAudio( false );

                          model.nsDemoRemotePlay.client = this._responder;

                        

                               model.videoRemote = new Video(model.videoRemoteWidth, model.videoRemoteHeight);

                               model.videoRemote.attachNetStream( model.nsDemoRemotePlay );                    

           model.nsDemoRemotePlay.play("assets/videos/Demo.flv");

      }

      I have two questions:Could anybody please help me in answering these.

      1. Is it possible to play a video without audio? I used receiveAudio( false ) with NetStream object. But audio is still there.

      2. How can I play a video play repeatedly? I want to play video repeatedly and stop it only when a Stop event is fired.

       

      Thanks.

      roshni.

        • 1. Re: How to play video repeatedly and with no audio
          Arun Lal Level 2

          Answer to 1)  :   videoDisplayObject.soundTransform.volume = 0

           

           

          Answer to 2)  : write the below statements in ur code.

           

          videoDisplayObject.autoRewind = true

           

          videoDisplayObject.addEventListener(VideoEvent.COMPLETE,videoCompleteHandler);

           

          private function videoCompleteHandler():void{
                videoDisplayObject.play();
          }

           

          Let me know if it helps

          • 2. Re: How to play video repeatedly and with no audio
            roshni79 Level 1

            Hello.

             

            Thanks for answers.

            1. Addition of below lines lowered volume but sound is still there.

            var nsst:SoundTransform=new SoundTransform(0,0);
            model.nsDemoRemotePlay.soundTransform=nsst;  

             

            2. I am using Video object and I could not find autoRewind property with Video. How can I do this with a Video object

             

            Thanks.

            roshni

            • 3. Re: How to play video repeatedly and with no audio
              kkc_mca Level 2

              NSObj.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);

               

              public function netStatusHandler(event:NetStatusEvent):void

              {

                   switch(event.info.code)

                   {

                        case "NetStream.Play.Start" :// your code

                                                                   break;

                        case "NetStream.Play.Stop" :// your code 

                                                                   break;

                   }

              }//end of netstatus handler function

               

               

              I hope my post will answer your question or helps

              • 4. Re: How to play video repeatedly and with no audio
                Arun Lal Level 2

                Instead of Video class try to use VideoDisplay class. VideoDisplay has autoRewind property.