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
Dragging and Magnifying a Sprite
MUSTARD
Royalty Free Music from NEO Sounds
Sarah"s Multiuser Pages
Initialize QuickTime Video (no white flash)
Slow Searches - Valentina
Shockwave Safe Xtras
Director and online database interaction
Mui Alert Dialog
Shocksites.com
 

 

 

Behavior import and play sound file (during runtime)

Added on 9/13/2003

 

Compatibilities:
behavior D8_5 D9 PC

Required Xtras:
Buddy API

This item has not yet been rated

Author: paenil1

Use this behaviour to import and play an external sound file (mp3 or wav) into your director movie during runtime. It will allow you to choose which sound channel to use and whether to loop it or not. *You can choose to have a different cast lib for this

--created by Lomi Paeniu
--with help from media man (MultimediaHelp Forum)
--feel free to use this script as you like
--drop me an email on paenil1@hotmail.com
--for any questions, feedback or suggestions

property pDirectory, pLoop, pSoundchannel, pFiletype, pCastlib

on getpropertyDescriptionList
  set description = [:]
  addprop description #pDirectory, [#format : #string, #comment :"Sound folder relative to the movie (include  after):", #default : ""]
  addprop description #pFiletype, [#format : #string, #comment :"File Type:", #default : "*.mp3", #range : ["*.mp3","*.wav"]]
  addprop description #pLoop, [#comment : "Loop (1 for yes, 0 for no):", #format : #integer, #default : "0", #range : [0,1]]
  addprop description #pSoundchannel, [#comment : "Sound channel:", #format : #integer, #default : 1, #range : [1,2,3,4,5,6,7,8]]
  addprop description #pCastlib, [#comment : "Which Cast Lib:", #format : #string, #default :""]
  return description
end


on beginsprite me
  --list and count files
  f = baFileList(the moviePath & pDirectory,pFileType)
  pFileCount = f.count
  --randomly select a file from the list
  r = random(f.count)
  --get the file name
  pName = f[r]
  --then import it
  pMember = new(#sound, castlib pCastlib)
  pMember.importFileInto(the moviePath & pDirectory & f[r])
  --apply the file name to the new member
  member(pMember).name = pName
  --loop the sound file
  member(pName).loop = pLoop
  --play the imported file
  sound(pSoundchannel).play(pMember)
  --fade in sound
  sound fadeIn pSoundchannel
end

 


Contact

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

Send e-mail