Sound Queue

From Director Online Wiki
Jump to: navigation, search

Sound Queue

Usage:

  queueSound( thefullpathsoundfile )

Teste for behaviors, events and so on:

  if checkSound() then abort
on checkSound()
  global gSoundQueue, gPlayingNow
  queueSoundProcess()
  return (gSoundQueue.count > 0)
end checkSound()
 
on queueSound( thesoundfile )
  global gSoundQueue 
  if voidp(gSoundQueue) then
    gSoundQueue = []
  end if
  gSoundQueue.add( thesoundfile )
end queueSound()
 
on queueSoundProcess()
  global gSoundQueue, gPlayingNow
  if voidp(gSoundQueue) then
    gSoundQueue = []
  end if
  if gSoundQueue.count > 0 then
     if not soundbusy(1) then
       if gSoundQueue[1] = gPlayingNow then
         gSoundQueue.deleteAt(1)
         gPlayingNow = 0
         cursor = -1
       end if
       if gSoundQueue.count > 0 then
         cursor = 4
         gPlayingNow = gSoundQueue[1]
         sound(1).playFile(gPlayingNow)
       end if
     end if
  end if
end queueSoundProcess