property pVideoSprite -- the FLV or MP4 sprite channel
property pWhichFrame -- the frame or marker to go to when the video plays to the end

--------------------------------------------------------------------
-- Attach this behavior to an FLV or MP4 video sprite.
--
-- This behavior will keep the playhead on a frame until the video
-- is finished playing. It will then go to a specified marker.
--
-- In order for this behavior to work with MPEG-4 videos you need
-- to choose the MP4 option when importing the video.
--
-- Ken Loge - http://diginoodles.com
-------------------------------------------------------------------

on beginSprite me
  pVideoSprite = sprite(me.spriteNum)
end

on getPropertyDescriptionList me
  list = [:]
  addProp list, #pWhichFrame, [#comment: "Marker to go to when video is finished playing:", #format: #marker, #default: ""]
  return list
end

on exitFrame me
  if sprite(pVideoSprite).currentTime < sprite(pVideoSprite).duration then
    -- stay on the current frame
    _movie.go(_movie.frame)
  else
    -- go to specified frame
    _movie.go(pWhichFrame)
  end if
end