Thread: array problem
View Single Post
  #2  
Old 02-25-2009, 10:41 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Here is an example script that uses the viztask module to loop through a playlist of songs. Let me know if anything is unclear.
Code:
import viz
import viztask
viz.go()

PLAYLIST = ['crash.wav','BOING!.WAV','quack.wav']

def PlayMusicTask(songs):
	"""Task that loops through a playlist of songs"""
	
	#Preload all songs
	songCycle = viz.cycle([ viz.addAudio(filename) for filename in songs ])
	
	#Loop indefinitely through song list
	while True:
		
		#Play next song
		song = songCycle.next()
		song.play()

		#Wait for song to end
		yield viztask.waitMediaEnd(song)

#Schedule music task
viztask.schedule( PlayMusicTask(PLAYLIST) )
Reply With Quote