6 Replies Latest reply on Mar 17, 2007 9:09 AM by snowmansmartie

    video player - help required

    snowmansmartie
      Hi Guys,

      I am sooooo new to Director, like 8hours into it. I need to create a video player but with a twist. Once the video starts I need to pause it, after a certian period of play and then play another shorter video.

      Once the 2nd shorter video has finished I need to resume the play of the 1st video!!

      Ok now, heres what I have got so far. The 1st video playing with a play and stop button, both of which work.

      I can see that I would need something like, the following piece of code to do what I need:

      if sprite(1).movieTime = 1000 then
      sprite(1).movieRate = 0
      -- enter code for playing of 2nd video
      end if

      If anyone can help to fill in the blanks, and also where to stick the code, I would be most grateful.

      Thanks in advance.
        • 1. Re: video player - help required
          Level 7
          You're most of the way there. If your first video is in channel 1, then
          put the second in channel 2. Do you want both to be on the screen at the
          same time, or do you want to only show one video at any time?

          If you have both on the screen at the same time, then you could use a
          behavior attached to the first video.

          ----------
          property thisSprite

          on beginSprite me
          thisSprite = me.spriteNum
          end

          on exitFrame me
          if sprite(thisSprite).movieTime >= 1000 then
          sprite(thisSprite).movieRate = 0
          sprite(2).movieRate = 1
          end if
          end
          ----------

          You want to use >= to test the movieTime because the exitFrame function
          might not look at the video at exactly that one correct time.

          To play the first again when the second is finished you can extend the
          code above like this:

          --------
          property thisSprite
          property otherVideoSprite
          property otherVideoDuration
          property stopFirst

          on getPropertyDescriptionList
          myPropList = [:]
          myPropList.addProp(#otherVideoSprite,[#comment:"enter the sprite
          channel number for the other video:",#format:#integer,#default:2])
          return myPropList
          end

          on beginSprite me
          thisSprite = me.spriteNum
          otherVideoDuration = sprite(otherVideoSprite).duration
          stopFirst = false
          end

          on exitFrame me
          if (sprite(thisSprite).movieTime >= 1000) and (stopFirst = false) then
          sprite(thisSprite).movieRate = 0
          sprite(otherVideoSprite).movieRate = 1
          stopFirst = true
          end if
          if (stopFirst = true) and (sprite(otherVideoSprite).movieTime >=
          otherVideoDuration) then
          sprite(thisSprite).movieRate = 1
          sprite(otherVideoSprite).movieRate = 0
          end if
          end
          ----------

          --
          Rob
          _______
          Rob Dillon
          Adobe Community Expert
          http://www.ddg-designs.com
          412-243-9119

          http://www.macromedia.com/software/trial/
          • 2. Re: video player - help required
            snowmansmartie Level 1
            Hi Rob,

            Thanks for your reply, I will check this code out and see how I get on.

            Just a couple of things, the videos need to be displayed one at a time, not both at the same time.

            The second thing is ........ well, I will try the code out 1st and see if what happens, lol!!!
            • 3. video player - help required
              snowmansmartie Level 1
              Hi,

              Ok I am getting a Property not found error as follows:

              otherVideoDuration = sprite(otherVideoSprite).duration

              #duration.

              I think I can see what the myPropList is doing, but I just dont get the point of it, is there not a way of setting otherVideoSprite to the value of the channel number it is on, without going through the properites list thing? Or am I missing something huge about the list?

              Just for more info I have the 1st video in Ch 1 frames 1 - 10 and the 2nd video in Ch2 frames 11 - 20, is this correct?

              Ok I have been playing around with the code and I have noe got this:

              property thisSprite
              property otherVideoSprite
              property otherVideoDuration
              property stopFirst

              --on getPropertyDescriptionList
              -- myPropList = [:]
              -- myPropList.addProp(#otherVideoSprite,[#comment:"enter ch numb for other video:", #format: #integer, #default:2])
              -- trace myPropList
              -- return myPropList
              --end

              on beginSprite me
              otherVideoSprite = sprite(2)
              otherVideoSprite.movieRate = 0
              otherVideoSprite.visible = false
              thisSprite = me.spriteNum
              otherVideoDuration = sprite(otherVideoSprite).duration
              stopFirst = false
              end

              on exitFrame me

              if (sprite(thisSprite).movieTime >= 1000) and (stopFirst = false) Then
              sprite(thisSprite).movieRate = 0
              sprite(thisSprite).visible = false
              sprite(3).visible = false
              sprite(4).visible = false
              sprite(otherVideoSprite).visible = true
              sprite(otherVideoSprite).movieRate = 1
              stopFirst = true
              end if

              if (stopFirst = true) and (sprite(otherVideoSprite).movieTime >= otherVideoDuration) Then
              sprite(otherVideoSprite).visible = false
              sprite(3).visible = true
              sprite(4).visible = true
              sprite(thisSprite).visible = true
              sprite(thisSprite).movieRate = 1
              end if
              end

              This works, yay!! ermmmmm ish!

              The 1st video plays to about 16secs, stops dissappears and the 2nd video plays full length, this is all good and works fine.

              Now the problem comes the 2nd video finishes and is supposed to dissappear, but cant quite do it, the 2nd video plays and the two are trying to compete for the player and all I get is a flickering between the 2 videos with the 1st one playing and stuttering all over the place.

              Cant see how to fix, any help would be greatly appreciated.

              All members on the score are now in 1 frame with a score script to loop at frame 1 ie _movie.go(_movie.frame).

              Thanks in advance.
              • 4. Re: video player - help required
                Level 7
                In article <etdqmc$p40$1@forums.macromedia.com>,
                "snowmansmartie" <webforumsuser@macromedia.com> wrote:

                > Hi,
                >
                > Ok I am getting a Property not found error as follows:
                >
                > otherVideoDuration = sprite(otherVideoSprite).duration
                >
                > #duration.
                >
                > I think I can see what the myPropList is doing, but I just dont get the
                > point
                > of it, is there not a way of setting otherVideoSprite to the value of the
                > channel number it is on, without going through the properites list thing? Or
                > am I missing something huge about the list?
                >
                > Just for more info I have the 1st video in Ch 1 frames 1 - 10 and the 2nd
                > video in Ch2 frames 11 - 20, is this correct?

                If you don't have anything in channel 2 when you use the behavior then,
                yes, you will get an error, because there's nothing there in channel 2
                in that frame.

                If you are staggering the sprites as you describe, then what you really
                want to do is to play the first video to movieTime 1000 and then move to
                a new frame and begin to play the second video. This is much simpler.

                Use something like this:

                ----------
                property thisSprite

                on beginSprite me
                thisSprite = me.spriteNum
                end

                on exitFrame me
                if sprite(thisSprite).movieTime >= 1000 then
                go to "video two"
                end if
                end
                ----------

                Put a frame marker at the first frame of the second video, frame 11.
                Name it "video two". Place the behavior above on the first video sprite.
                When the first video gets to movieTime 1000, this behavior will push the
                playback head to the frame that holds that frame label. Your second
                video will play. The first will stop because it's not in that frame.

                --
                Rob
                _______
                Rob Dillon
                Adobe Community Expert
                http://www.ddg-designs.com
                412-243-9119

                http://www.macromedia.com/software/trial/
                • 5. Re: video player - help required
                  snowmansmartie Level 1
                  thanks Rob,

                  I actually managed to figure out the solution, but your original code got me started, so I am really grateful for your help.
                  • 6. Re: video player - help required
                    snowmansmartie Level 1
                    Hi,

                    I have moved my project on slightly. I have inserted the ActiveX control Windows Media Player. This is fine.

                    All I need to be able to do now is to pull the video files from the hard drive (this will eventually be a folder or database on a webserver - ill cross that bridge when I come to it!!) and play them in the media player.

                    Can anyone help me out with this one?

                    thanks for your help in advance.

                    Regards