3
#include <SDL/SDL_mixer.h>
5
#include <emscripten.h>
7
Mix_Chunk *sound, *sound2;
12
int channel = Mix_PlayChannel(-1, sound, 1);
15
emscripten_run_script("setTimeout(Module['_play2'], 500)");
19
void done(int channel) {
27
Mix_ChannelFinished(done);
29
int channel2 = Mix_PlayChannel(-1, sound2, 1);
30
assert(channel2 == 1);
34
int main(int argc, char **argv) {
35
SDL_Init(SDL_INIT_AUDIO);
37
int ret = Mix_OpenAudio(0, 0, 0, 0); // we ignore all these..
40
sound = Mix_LoadWAV("sound.ogg");
42
sound2 = Mix_LoadWAV("sound2.wav");
46
printf( "Pausing Channel %d", channel );
48
int paused = Mix_Paused(channel);
49
printf( "Channel %d %s", channel, paused ? "is paused" : "is NOT paused" );
52
paused = Mix_Paused(channel);
53
printf( "Channel %d %s", channel, paused ? "is paused" : "is NOT paused" );
56
if (argc == 12121) play2(); // keep it alive
58
emscripten_run_script("element = document.createElement('input');"
59
"element.setAttribute('type', 'button');"
60
"element.setAttribute('value', 'replay!');"
61
"element.setAttribute('onclick', 'Module[\"_play\"]()');"
62
"document.body.appendChild(element);");
64
printf("you should hear two sounds. press the button to replay!\n");