Merge branch 'sd-audio' of github.com:michaeljbishop/emscripten into michaeljbishop-sd-audio
This commit is contained in:
Коммит
daed1bdade
|
@ -1463,10 +1463,66 @@ var LibrarySDL = {
|
|||
return (SDL.music.audio && !SDL.music.audio.paused) ? 1 : 0;
|
||||
},
|
||||
|
||||
// http://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_38.html#SEC38
|
||||
// "Note: Does not check if the channel has been paused."
|
||||
Mix_Playing: function(id) {
|
||||
if (id === -1) {
|
||||
var count = 0;
|
||||
for (var i = 0; i < SDL.audios.length; i++)
|
||||
count += SDL.Mix_Playing(i);
|
||||
return count;
|
||||
}
|
||||
var info = SDL.audios[id];
|
||||
if (info && info.audio && !info.audio.paused)
|
||||
return 1;
|
||||
return 0;
|
||||
},
|
||||
|
||||
Mix_Pause: function(id) {
|
||||
if (id === -1) {
|
||||
for (var i = 0; i<SDL.audios.length;i++)
|
||||
SDL.Mix_Pause(i);
|
||||
return;
|
||||
}
|
||||
var info = SDL.audios[id];
|
||||
if (info && info.audio)
|
||||
info.audio.pause();
|
||||
},
|
||||
|
||||
// http://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_39.html#SEC39
|
||||
Mix_Paused: function(id) {
|
||||
if (id === -1) {
|
||||
var pausedCount = 0;
|
||||
for (var i = 0; i<SDL.audios.length;i++)
|
||||
pausedCount += SDL.Mix_Paused(i);
|
||||
return pausedCount;
|
||||
}
|
||||
var info = SDL.audios[id];
|
||||
if (info && info.audio && info.audio.paused) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
},
|
||||
|
||||
Mix_PausedMusic: function() {
|
||||
return (SDL.music.audio && SDL.music.audio.paused) ? 1 : 0;
|
||||
},
|
||||
|
||||
// http://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_33.html#SEC33
|
||||
Mix_Resume: function(id) {
|
||||
if (id === -1)
|
||||
{
|
||||
for (var i = 0; i<SDL.audios.length;i++)
|
||||
SDL.Mix_Resume(i);
|
||||
return;
|
||||
}
|
||||
var info = SDL.audios[id];
|
||||
if (info && info.audio)
|
||||
{
|
||||
info.audio.play();
|
||||
}
|
||||
},
|
||||
|
||||
// SDL TTF
|
||||
|
||||
TTF_Init: function() { return 0 },
|
||||
|
|
|
@ -6,13 +6,14 @@
|
|||
|
||||
Mix_Chunk *sound, *sound2;
|
||||
|
||||
void play2();
|
||||
int play2();
|
||||
|
||||
void play() {
|
||||
int play() {
|
||||
int channel = Mix_PlayChannel(-1, sound, 1);
|
||||
assert(channel == 0);
|
||||
|
||||
emscripten_run_script("setTimeout(Module['_play2'], 500)");
|
||||
return channel;
|
||||
}
|
||||
|
||||
void done(int channel) {
|
||||
|
@ -22,11 +23,12 @@ void done(int channel) {
|
|||
REPORT_RESULT();
|
||||
}
|
||||
|
||||
void play2() {
|
||||
int play2() {
|
||||
Mix_ChannelFinished(done);
|
||||
|
||||
int channel2 = Mix_PlayChannel(-1, sound2, 1);
|
||||
assert(channel2 == 1);
|
||||
return channel2;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
@ -40,7 +42,17 @@ int main(int argc, char **argv) {
|
|||
sound2 = Mix_LoadWAV("sound2.wav");
|
||||
assert(sound);
|
||||
|
||||
play();
|
||||
int channel = play();
|
||||
printf( "Pausing Channel %d", channel );
|
||||
Mix_Pause(channel);
|
||||
int paused = Mix_Paused(channel);
|
||||
printf( "Channel %d %s", channel, paused ? "is paused" : "is NOT paused" );
|
||||
assert(paused);
|
||||
Mix_Resume(channel);
|
||||
paused = Mix_Paused(channel);
|
||||
printf( "Channel %d %s", channel, paused ? "is paused" : "is NOT paused" );
|
||||
assert(paused == 0);
|
||||
|
||||
if (argc == 12121) play2(); // keep it alive
|
||||
|
||||
emscripten_run_script("element = document.createElement('input');"
|
||||
|
|
Загрузка…
Ссылка в новой задаче