Sound Actuator Loop Bidirectional: time

time
  • get: gets the amount of time a sound has been playing.
  • set: restarts the sound at this point of time in the audio track while the sound is playing.

Type: 
  • float number
     
  • Returns 0.00 if the sound isn't playing.
Loop Bidirectional:
  • Plays the sound file from start to finish.  Then finish to start.  Over and over.
  • Positive Pulse:  Starts playing the sound file from the beginning.
  • Negative pulse:  Keeps playing the sound file until it reaches the end, then stops playing.
Sample Code


################  get the amount of time the sound has been playing.

# import bge module
import bge

# get the controller
cont = bge.logic.getCurrentController()

# get the actuator attached to the controller
# my actuator is named Song

act = cont.actuators["Song"]

# get amount of time
amount = act.time
 
Sample Code


################  restart the sound at this point of the audio track

# import bge module
import bge

# get the controller
cont = bge.logic.getCurrentController()

# get the actuator attached to the controller
# my actuator is named Song

act = cont.actuators["Song"]

# set sound to start at 10
act.time = 10.00