Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
Write Text to File Example
QuickTime Notes
Effector Set 1 Behavior Support
Bitbull
Cursor trails
FrameReady()
Custom Radio/Check Box
cXtraGraphicIO
Gravis MouseStick
Easy Dialog
 

 

 

Behavior All in one video controller

Added on 11/10/1999

 

Compatibilities:
behavior D7 D8 Mac PC Shockwave

Rating:

Author: MediaMacros (website)

This behavior controls digital video, all the necessary buttons, and an interactive slider bar.

--Copyright 1999 Chuck Neal
--chuck@mediamacros.com
--If you find this code helpful, send me an e-mail and let me know. :-)

property spriteNum, whatItem, sliderList

on getPropertyDescriptionList me
  p_list = [:]
  if [#quickTimeMedia, #digitalVideo].getOne(sprite(the currentSpriteNum).member.type) = 0 then
    p_list.addProp(#whatItem, [#format : #symbol, #comment : "Which element:", #default : #play, #range : [#play, #stop, #rewind, #fast, #pause, #slider, #sliderBar, #counter]])
  end if
  return p_list
end

on beginSprite me
  if whatItem = #slider then
    barList = [:]
    sendAllSprites(#getSliderBar, barList)
    if barList.count < 2 then
      alert "Please place the slider bar and video sprite in a lower sprite channel than the slider!"
    else
      sliderList = barList
      calcLoc()
    end if
  end if
end

on getSliderBar me, barList
  if [#quickTimeMedia, #digitalVideo].getOne(sprite(spriteNum).member.type) <> 0 then
    barList[#video] = spriteNum
  else if whatItem = #sliderBar then
    barList[#sb] = spriteNum
  end if
end

on calcLoc me
  if whatItem = #slider then
    percentage = sprite(sliderList[#video]).movieTime / float(sprite(sliderList[#video]).member.duration)
    sprite(spriteNum).loc = point(sprite(sliderList[#sb]).left + (sprite(sliderList[#sb]).width * percentage),sprite(sliderList[#sb]).locV)
  end if
end

on exitFrame me
  if whatItem = #slider then
    calcLoc()
  end if
end

on mouseUp me
  case whatItem of
    #play ,#stop, #pause :
      sendAllSprites(#doVideo, whatItem)
  end case
end

on jumpVideo me, whatPercentage
  if [#quickTimeMedia, #digitalVideo].getOne(sprite(the currentSpriteNum).member.type) <> 0 then
    sprite(spriteNum).movieTime = whatPercentage * sprite(spriteNum).member.duration
  end if
end

on mouseDown me
  case whatItem of
    #rewind, #fast:
      sendAllSprites(#doVideo, whatItem)
    #slider :
      oldRate = sprite(spriteNum).movieRate
      sprite(spriteNum).movieRate = 0
      repeat while the stillDown
        newH = the mouseH
        if newH < sprite(sliderList[#sb]).left then
          newH = sprite(sliderList[#sb]).left
        else if newH > sprite(sliderList[#sb]).right then
          newH = sprite(sliderList[#sb]).right
        end if
        sprite(spriteNum).loc = point(newH, sprite(sliderList[#sb]).locv)
        percentage = (newH - sprite(sliderList[#sb]).left) / float(sprite(sliderList[#sb]).width)
        sendAllSprites(#jumpVideo, percentage)
        updateStage
      end repeat
      sprite(spriteNum).movieRate = oldRate
  end case
end

on doVideo me, doItem
  if [#quickTimeMedia, #digitalVideo].getOne(sprite(spriteNum).member.type) <> 0 then
    case doItem of
      #play :
        sprite(spriteNum).movieRate = 1
      #stop :
        sprite(spriteNum).movieRate = 0
        sprite(spriteNum).movieTime = 0
      #rewind :
        oldRate = sprite(spriteNum).movieRate
        sprite(spriteNum).movieRate = -2
        repeat while the stillDown
          sendAllSprites(#calcLoc)
          updateStage
        end repeat
        sprite(spriteNum).movieRate = oldRate
      #fast :
        oldRate = sprite(spriteNum).movieRate
        sprite(spriteNum).movieRate = 2
        repeat while the stillDown
          sendAllSprites(#calcLoc)
          updateStage
        end repeat
        sprite(spriteNum).movieRate = oldRate
      #pause :
        sprite(spriteNum).movieRate = 0
    end case
  end if
end

on getBehaviorDescription me
  describe = "Drop this on the video sprite and all the controller buttons and slider pieces."
  describe = describe & return & "Make sure the slider bar and movie are in a lower channel than the slider." & return & "Everything else is automatic."
  return describe
end  

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail