blob: 2539b982f04a6b77bb406487bb27e46755d0890f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#include <stdio.h>
#include <SDL/SDL.h>
#include <SDL/SDL_mixer.h>
#include <assert.h>
#include <emscripten.h>
Mix_Chunk *sound;
void play() {
int channel = Mix_PlayChannel(-1, sound, 1);
assert(channel >= 0);
}
int main() {
SDL_Init(SDL_INIT_AUDIO);
int ret = Mix_OpenAudio(0, 0, 0, 0); // we ignore all these..
assert(ret == 0);
sound = Mix_LoadWAV("sound.ogg");
assert(sound);
play();
emscripten_run_script("element = document.createElement('input');"
"element.setAttribute('type', 'button');"
"element.setAttribute('value', 'replay!');"
"element.setAttribute('onclick', '_play()');"
"document.body.appendChild(element);");
printf("you should hear a victory sound. press the button to replay!\n");
int result = 1;
REPORT_RESULT();
return 0;
}
|