How do I...?

Play Multiple Audio Files in Sequence

In AutoPlay Media Studio, it is possible to play one audio file after another using the On Audio event.

As an example, we will create a project that when run will load three files into a table, and play them back-to-back until the third song is finished.

To accomplish this:

  1. Insert the following code into your Global Functions (click Project > Global Functions):

-- keep track of the audio files
audio_count = 1;

--loads desired audio files into a table
audio = {
"Autoplay\\Audio\\audio_file1.ogg",
"Autoplay\\Audio\\audio_file2.ogg",
"Autoplay\\Audio\\audio_file3.ogg"
};

  1. Insert the following code into the On Show event of your page:

Audio.Load(CHANNEL_USER1, audio[audio_count], true, false);
Insert the following code into the On Audio event of your page:
if e_State == "Finish" then
    audio_count = audio_count + 1;
    --ensures a valid file will be loaded
    if audio_count < Table.Count(audio)+1 then
        Audio.Load(CHANNEL_USER1, audio[audio_count], true, false);
    end
end

Сайт управляется системой uCoz