I have the following actionscript which plays an mp3.
Code:
var s:Sound = new Sound();
var sc:SoundChannel;
s.load("my_song.mp3");
sc = s.play();
import flash.external.ExternalInterface;
ExternalInterface.call("alert", sc.position);
I want the alert call to be activated every 100ms during the playback. I have no idea how to do this. I need to add some sort of eventlistener to the playback so that it triggers the alert every 100ms... Any ideas?
That wouldn't work.... if anything happens to the playback ... then the alerts will continue coming. Or if the playback is delayed a bit ...the alerts will come out of sync.
ok, half of that was impossible for my pea brain to understand... the other half did not have what i was looking for.
I guess the only solution, which i was trying to avoid is to do a setInterval which will run every 50ms to check the playback position. If the playback position is within certain limits then it will alert the message.
I wish i had found a more intelligent work around though
The first article is a bit complex I understand, but it covers making a class which is then used to provide information about the audio file. Are you planning on streaming this audio? I would think that if you buffer the item it would be fine in most situations, but what are you sending to the alert?
Also there is a .onSoundComplete event which allows you to clear the interval when this occurs, so the alert stops.
__________________
jeremy - gnomeontherun Educated questions often get educated answers, and simple questions often get simple answers.
the alert will actually be a gotoandStop function which will show a particular frame depending on the position of the sound being played. I know this can be done in AS3... but this is an AS2 solution.
You could use cue points in the audio file (which is the first that I liked to, which is likely the one that caused you some headaches), and here is a great guide to audio (without cues) that I just came across. I just can't find any good resources either for cues besides that one article.