8 Replies Latest reply on Oct 25, 2007 3:38 AM by andyulrika_is_back

    Windows Media File Stops at Start!

    andyulrika_is_back Level 1
      Hello

      Can someone please help.

      I have a windows media file playing on my stage when the playhead enters the frame. I'm trying to get the WMF to play through to the end and stop, instead of returning to the first frame and stopping.

      Does anybody know how I can achieve this?

      Thanks in advance.

      Andy

        • 1. Re: Windows Media File Stops at Start!
          robdillon Most Valuable Participant
          You need to stop the wmf before it gets to the end. You can do that with a behavior attached to the wmf sprite, something like this:

          property thisSprite
          property thisDuration

          on beginSprite me
          thisSprite = me.spriteNum
          thisDuration = sprite(thisSprite).member.duration
          end

          on exitFrame me
          if sprite(thisSprite).movieTime > thisDuration -10 then
          sprite(thisSprite).stop()
          end if
          end

          You may need to adjust the number of frames to subtract from the duration value to get the video to stop at the right place.
          • 2. Re: Windows Media File Stops at Start!
            andyulrika_is_back Level 1
            Hi Rob

            Thanks for the code. Unfortunately, I couldn't get it to work, it had no effect on my movie.

            I tried modifying it slightly to the following -

            property thisSprite
            property thisDuration

            on beginSprite me
            thisSprite = me.spriteNum
            thisDuration = sprite(thisSprite).member.duration
            if sprite(thisSprite).movieTime > thisDuration -15 then
            sprite(thisSprite).stop()
            end if
            end


            My wmf is currently 15.7 seconds long. Am I doing something wrong?

            Thanks in advance.

            Andy
            • 3. Re: Windows Media File Stops at Start!
              Level 7
              andyulrika_is_back wrote:
              > property thisSprite
              > property thisDuration
              >
              > on beginSprite me
              > thisSprite = me.spriteNum
              > thisDuration = sprite(thisSprite).member.duration
              > if sprite(thisSprite).movieTime > thisDuration -15 then
              > sprite(thisSprite).stop()
              > end if
              > end
              >
              >
              > My wmf is currently 15.7 seconds long. Am I doing something wrong?

              You want to check the movieTime in an exitFrame handler, rather than just
              once when the sprite begins:

              -----------------------------------------------
              property thisSprite
              property thisDuration

              on beginSprite me
              thisSprite = sprite(me.spriteNum)
              thisDuration = thisSprite.member.duration
              end

              on exitFrame
              if thisSprite.movieTime > thisDuration -15 then
              thisSprite.stop()
              end if
              end
              -----------------------------------------------

              HTH

              Andrew


              • 4. Re: Windows Media File Stops at Start!
                andyulrika_is_back Level 1
                Hi Andrew

                Thanks for your input, I still don't get it. Okay, so I want to check my movietime on an exitframe. But, how do I actually get the movie to stop near the end, it's still not doing anything - I'm just dropping this script onto the wmf - nothing happening.

                Any help much appreciated.

                Andy
                • 5. Re: Windows Media File Stops at Start!
                  Level 7
                  andyulrika_is_back wrote:
                  > Thanks for your input, I still don't get it. Okay, so I want to check
                  > my movietime on an exitframe. But, how do I actually get the movie to
                  > stop near the end, it's still not doing anything - I'm just dropping
                  > this script onto the wmf - nothing happening.

                  Careful: .wmf=Windows Metafile which is a still-image vector graphics
                  format.

                  Anyway, I missed that .stop is for Flash sprites; for digital video, set the
                  .movieRate to 0.

                  on exitFrame
                  if thisSprite.movieTime > (thisDuration -15) then
                  thisSprite.movieRate=0
                  end if
                  end

                  Andrew


                  • 6. Re: Windows Media File Stops at Start!
                    andyulrika_is_back Level 1
                    Thanks for the amended code. But, my movie still returns to the first frame. I just want the playhead to loop on 1 frame until it plays to the end, then stop at the end and not return to the first frame.

                    Any ideas?

                    Thanks

                    Andy
                    • 7. Re: Windows Media File Stops at Start!
                      robdillon Most Valuable Participant
                      I posted a solution a couple of days ago, but it doesn't seem to be here any longer. WMV files will always return to the first frame when they are stopped. Use pause() instead of stop() as the command to halt the movie's play. When a WMV reaches the end of the file, it will always return to the first frame of the file. So to hold at the end of the file, you have to stop the file before it ends.

                      Try something like this:

                      -------------
                      property thisSprite
                      property thisDuration

                      on beginSprite me
                      thisSprite = me.spriteNum
                      thisDuration = sprite(thisSprite).member.duration - 20
                      -- change the number to subtract as needed to get the movie to stop at the appropriate point.
                      end

                      on exitFrame me
                      if sprite(thisSprite).currentTime >= thisDuration then
                      sprite(thisSprite).pause()
                      end if
                      end
                      ----------------

                      WMV files use the currentTime property instead of the movieTime property that QT sprites use.
                      • 8. Re: Windows Media File Stops at Start!
                        andyulrika_is_back Level 1
                        Many thanks Rob

                        Works a treat. I've just realised that the time duration amount is the amount of time from the end.

                        Thanks all for your input.

                        Regards

                        Andy