array problem
Hello!
I have made a playlist of songs, which in fact is an array, and I am trying to play the songs by using a for loop (I want to have constantly music at the background). The problem is that it plays all the songs at once and as I can understand a timer that expires very quickly (I use this timer for the joystick) is responsible for that. I think I have to use another timer, but I have no idea what expiration time it should have, how many repeats, when to start it etc. Can you give me any suggestions before I send my code? Thanks Maria |
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 |
Thanks for the quick reply (you've saved me a lot of time!)
The only unclear thing is the following line: songCycle = viz.cycle([ viz.addAudio(filename) for filename in songs ]) It will load the songs as it is or I have to change something? (ie replace the "filename" with the first (actual) filename in songs?) I also met another problem. I had these errors when I run the code: Traceback (most recent call last): File "C:\Program Files\WorldViz\Vizard30\python\viztask.py", line 685, in _onupdate self._tasks = [ t for t in self._tasks if not t.update() ] File "C:\Program Files\WorldViz\Vizard30\python\viztask.py", line 652, in update val = self.__stack[-1].next() File "museum.py", line 78, in PlayMusicTask songCycle = viz.cycle([ viz.addAudio(filename ) for filename in songs ]) File "C:\Program Files\WorldViz\Vizard30/python\viz.py", line 7524, in addAudio return VizAudio(_ipcSend(_VIZ_ADDAUDIO,0,0,fileName,0.0,0 .0,0.0,0.0),**kw) TypeError: message must be a string |
Did you get that error by running the exact code I posted?
That line of code creates a cycle of audio objects from the file names. All you have to change is the PLAYLIST variable to contain all the filenames of songs you want to play. |
It was the exact code! The only different thing was the PLAYLIST, where I had replaced the sounds with my songs :-)
|
:confused: So it wasn't the exact code? I'm assuming you incorrectly defined the PLAYLIST variable. I can't provide anymore help unless you post the code you are using.
|
You were right. I fixed the problem.
Thanks a lot for your help and time! |
Only cycle through once?
Hello, the code you helped with here has a loop to indefinetly loop through the songs. What if i want the loop to go through each element in the array only once? is there a way to detect that?
Thanks, Nicole |
Since you're not going to cycle through the songs you could use a standard list and a for loop:
Code:
#Preload all songs |
All times are GMT -7. The time now is 08:40 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC