5 Replies Latest reply on Dec 31, 2009 6:33 AM by David_F57

    Simple Video question

    kylesmark

      I have 6 video displays, and when you Play one i want the others to stop..  but if there not playing i get a error because im referenceing null.

      is there some built in var that says the video is playing? or a better way to do this? im useing a spark video player. im new to flex also

      please help

       

      public

       

       

      function ChangeVideo8():void {

      Video1.source =

      "../video/makeover.flv";

      Video1.play();

      Video0.pause();

      Video2.pause();

      Video3.pause();

      Video4.pause();

      Video5.pause();

      }

        • 1. Re: Simple Video question
          George Donn

          You might want to have some simple conditionals checking wither your object is null. It will be your best bet.
          OR

          When someone clicks the play event on video 1 the boolean flag will be set to true and when it is paused set the boolean to false.

          1 person found this helpful
          • 2. Re: Simple Video question
            kylesmark Level 1

            how would i check if a video player is null or (if there is no video being played)?

             

            i understand the 2nd part but no idea how to edit the play() of a spark video player?

             

             

            thanks for the help!

            • 3. Re: Simple Video question
              George Donn Level 1

              here is a good reference what you can follow - might be the best way to handle your issue - I believe I was incorrect for check if play() method is null etc..

              http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Liv eDocs_Parts&file=00000252.html

              • 4. Re: Simple Video question
                kylesmark Level 1

                sorry maybe im not that clear... i get this error:

                 

                TypeError: Error #1009: Cannot access a property or method of a null object reference.
                at KyleVideoExperiment/ChangeVideo8()
                at KyleVideoExperiment/___KyleVideoExperiment_Button3_click()

                 

                // i thought i was getting this error because not all videos are playing. so i played them all and stopped them but still got the error

                 

                public

                 

                 

                 

                 

                 

                function ChangeVideo8():void {

                Video1.source =

                "../video/makeover.flv";

                Video1.play();

                Video0.play();

                Video2.play();

                Video3.play();

                Video4.play();

                Video5.play();

                Video0.pause();

                Video2.pause();

                Video3.pause();

                Video4.pause();

                Video5.pause();

                }

                 

                 

                 

                // here is my video player if that helps

                 

                xmlns:s="

                 

                library://ns.adobe.com/flex/spark" width="1024" height="5000" backgroundColor="#635F5F" xmlns:mx="library://ns.adobe.com/flex/halo">

                 

                 

                 

                <s:VideoPlayer

                id= "

                Video2"

                source="

                ../video/SankVision7.flv"

                horizontalCenter="

                -228"

                verticalCenter="

                -2145"

                autoPlay="

                true" width="524" height="418"/>

                 

                 

                Your Link is very helpfull i can see how to set variables i think in running the proc. i guess i was just curious if it works the above way somehow, you would think something like this should be simple

                • 5. Re: Simple Video question
                  David_F57 Level 5

                  Hi,

                   

                  You could try something like this

                   

                  private function testandSetVideo(value:VideoPlayer): void

                  {

                  if (video0 != null && video0.playing==true && value != Video0) video0.pause();

                  if (video1 != null && video1.playing==true && value != Video1) video1`.pause();

                  if (video2 != null && video2.playing==true && value != Video2) video2.pause();

                  // for as many players as you have;

                   

                  }

                   

                  for instance if you press play on video2 for an onclick event you could do testandSetVideo(video2) and everything would pause except the new one playing.

                   

                  Or you could just pause them all then after they are all paused play the passed video player

                   

                  private function testandSetVideo(value:VideoPlayer): void

                  {

                   

                  if (video0 != null && video0.playing==true) video0.pause();

                   

                  if (video1 != null && video1.playing==true) video1`.pause();

                  if (video2 != null && video2.playing==true) video2.pause();

                   

                   

                  // for as many players as you have;

                  value.play();

                   

                  }

                  David.