Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Slider to control QT video

Status
Not open for further replies.

trock0002

Technical User
Feb 2, 2004
1
US
Hi,
I need help in constructing a slider to control my QT video. By sliding the slider (left or right), it cues or reverses the video. Once left alone the slider acts as a status marker to show how much of the movie is played. Thanks ahead of time.
-JT
 
Here’s basic Video slider controller behaviour.
- The slider moves from left to right as the video plays
- You can drag the slider to control the video back and forwards
- When you release the slide, the video continue to play

You’ll need to modify the Sprite number, the name of the video member and the position of the slider in the script to match your particular project.

Movie script
Code:
--
global videoChannel, videoDuration
global sliderChannel, sliderLeft, sliderRight

on prepareMovie
  -- Initiate global variables
  -- Sprite number of the QuickTime video
  videoChannel = 1
  -- Get the duration of the video
  videoDuration = member("QuickTime movie").duration
  -- Sprite number of the slider
  sliderChannel = 3
  -- Left most position of the slider
  sliderLeft = 80
  -- Right  most position of the slider
  sliderRight = 230
end prepareMovie
--

Slider behaviour (attach this script to the slider)
Code:
--
global videoChannel, videoDuration
global sliderChannel, sliderLeft, sliderRight

property sliderControl

on beginSprite me
  sliderControl = 0
  sprite(me.spriteNum).locH = sliderLeft
end beginSprite

on enterFrame me
  if sliderControl < 1 then
    if sprite(videoChannel).movieTime < videoDuration then sprite(videoChannel).movieRate = 1
    sprite(me.spriteNum).locH = (sliderRight - sliderLeft) * sprite(videoChannel).movieTime / videoDuration + sliderLeft
  else
    sprite(videoChannel).movieRate = 0
    if the mouseH < sliderLeft then
      sprite(me.spriteNum).locH = sliderLeft
    else if the mouseH > sliderRight then
      sprite(me.spriteNum).locH = sliderRight
    else
      sprite(me.spriteNum).locH = the mouseH
    end if
    sprite(videoChannel).movieTime = (sprite(me.spriteNum).locH - sliderLeft) * videoDuration / (sliderRight - sliderLeft)
  end if  
end enterFrame

on mouseDown me
  sliderControl = 1
end mouseDown

on mouseUp me
  sliderControl = 0
end mouseUp

on mouseUpOutside me
  sliderControl = 0
end mouseUpOutside
--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top