- Home /
How To set the start time of an audiosource
Hey
I want my game to remember where the music left off if you quit the application. Can someone explain to me why the following doesn't seem to work and how to properly set the start time of an audio source:
var test : AudioSource;
function Start() { test.time = 3.00; test.Play(); print (test.time); }
The print gives a number close to 0 like 0.27xxx I'm using an Mp3 for the music, and I'm working with unity iphone.
Thanks! you all rock!
Cheers
Vin
Answer by duck · Apr 04, 2010 at 01:26 PM
I think with mp3 sounds, because of the method of compression where the sound data is split into discrete 'frames', there's a limit to the resolution at which you can specify any given time within the sound.
You might find that if you use uncompressed sound, you get a finer degree of accuracy, however this will of course inflate the filesize a lot.
Hey wow, thanks for the ultra fast reply! I don't need it to be super accurate, but if i change the value to say 40. It still starts a 0. it just doesn't change at all!
thanks again!
Hm, strange. Have you tried swapping the order around, so you call Play() first, then set the time on the next line?
Thats it! starting the audio first makes it work! thanks a lot!
@Duck - congrats, o Lord of Unity! :) Try to use your powers wisely...
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Trying to delay movement of a GameObject 1 Answer
deltatime glitches 1 Answer
Problem with time !! help me 1 Answer
problem with the digits of my timer 1 Answer