Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: M on Wed 14/01/2004 22:25:54

Title: GetMP3PosMillis ()
Post by: M on Wed 14/01/2004 22:25:54
Hey. I'm having a bit of trouble getting this function to work. I've got an mp3 playing, I want something to happen at 7 seconds so - in the 'repeatedly execute' part I've got the code:

if (GetMP3PosMillis () == 7000) {

//do something

}

But nothing happens. I've played the mp3 with PlayMp3File() . Its probably something really simple but any one got any ideas?
Title: Re:GetMP3PosMillis ()
Post by: Scorpiorus on Wed 14/01/2004 23:28:44
At first, I'd check a returned value:

repeatedly_execute:

Display("Position: %d", GetMP3PosMillis ());

What does it display? (EDIT: ps you need to press a key to retrace if it's changed at all - just hold down the enter or something)
Title: Re:GetMP3PosMillis ()
Post by: M on Wed 14/01/2004 23:43:55
Yeah, got a returned value and it changes. I've managed to get it to work by putting in one of the numbers I saw displayed. It works if I put 7288 instead of 7000.

Hmm.. I don't remember reading in the documentation that it has to be in multiples of something. Thanks for the help, Scorpious.
Title: Re:GetMP3PosMillis ()
Post by: Scorpiorus on Wed 14/01/2004 23:55:19
Oh, yeah it's maybe (not sure) related to the technical side of mp3 format. EDIT: Another thing is that repeatedly_execute is called each 1/GetGameSpeed() of a second while mp3 file is continously being played by AGS in the background. That is why there is "GetMP3PosMillis greater than value" comparison example in the manual. :P

~Cheers
Title: Re:GetMP3PosMillis ()
Post by: Pumaman on Sat 17/01/2004 12:14:56
Yeah, exactly - for your comparison to work, your script would have to be executed at that exact millisecond. Therefore, you should always use a greater-than-or-equal-to test, not just equals, with this function.