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
System Tools
Drag&Drop Xtra
Import SWA (Shockwave Audio)
Sound pan, rate shift
Copy Keydown Script
Advanced Installer Professional
Case sensitive string comparison
BorderPatch
Change ShapeType of a Shape Sprite
Start Menu(xml)
 

 

 

Behavior SarSoft MediaPlayer - All in one video

Added on 7/14/2003

 

Compatibilities:
D7 D8 D8_5 D9

Required Xtras:
MediaPlayer Xtra

This item has not yet been rated

Author: zkos (website)

This behavior controls SarSoft MediaPlayer Xtra, all the necessary buttons, and an custom slider bar.

--Copyright By Zoran Kos 2003
--zkos@kos.co.yu

--Modified from Chuck Neal's All in one video

--If you find this code helpful, send me an e-mail and let me know. :-)

property spriteNum, whatItem, sliderList, myVideoSprite
global myVideoSprite

on getPropertyDescriptionList me
  p_list = [:]
  
  if (sprite(the currentSpriteNum).member.type) <>#mediaplayer 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 (sprite( the currentSpriteNum).member.type) = #mediaplayer 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]).position / float(sprite(sliderList[#video]).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 (sprite( the currentSpriteNum).member.type) = #mediaplayer THEN
    
    put integer(whatPercentage * sprite(spriteNum).duration)
    sprite(spriteNum).position = integer (whatPercentage * sprite(spriteNum).duration)
  end if
end

on mouseDown me
  case whatItem of
    #rewind, #fast:
      sendAllSprites(#doVideo, whatItem)
      
    #slider :
      oldRate = sprite(the currentSpriteNum).movieRate
      sprite(the currentSpriteNum).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 (sprite( the currentSpriteNum).member.type) = #mediaplayer then
    case doItem of
      #play :
        sprite(spriteNum).Play()
      #stop :
        Result= sprite(the currentSpriteNum).Stop()
        
      #rewind :
        
      
        oldRate = sprite(spriteNum).position
        
        repeat while the stillDown
        
          sprite(spriteNum).position =sprite(spriteNum).position - 5
          
          sendAllSprites(#calcLoc)
          updateStage
        end repeat
        sprite(spriteNum).movieRate = oldRate
      #fast :
        oldRate = sprite(spriteNum).Rate
        
        repeat while the stillDown
          sprite(spriteNum). Rate = 200
          sendAllSprites(#calcLoc)
          updateStage
        end repeat
        sprite(spriteNum).Rate = oldRate
      #pause :
        sprite(spriteNum).Pause()
        
          
    end case
  end if
end

on enterFrame me
  
  if (sprite( the currentSpriteNum).member.type) = #mediaplayer THEN
    myVideoPos = sprite(me.spriteNum).position
    
    sendAllSprites(#myCount,myVideoPos )
    
  end if
  

on myCount me, myVideoPos
  if whatItem = #counter then

        sprite(me.spritenum).member.text =  string(myVideoPos/100) && "sec/10"
  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