EXPORT BOOL WINAPI m_startSound(SWFSoundInstance *p1, SWFSound sound, int p3, int p4) { lstrcpy(funcname, "m_startSound"); *p1 = SWFMovie_startSound(mhsp_movie, sound); if (!mhsp_instance) { mhsp_instance = *p1; } return 0; }
void runTrimmedSoundsTest(SWFMovie mo, SWFSound so, int* frame) { SWFSoundInstance so_in; SWFMovie_nextFrame(mo); add_actions(mo, "note('\nTrimmed Sound Test.\n" "The notes should start exactly at the beginning of a frame " "(to coincide with the appearance of the description text');"); // outPoint so_in = SWFMovie_startSound(mo, so); SWFSoundInstance_setLoopOutPoint(so_in, 44100*2); printFrameInfo(mo, 0, "Two notes (C, E)"); SWFMovie_nextFrame(mo); (*frame)++; // inPoint so_in = SWFMovie_startSound(mo, so); SWFSoundInstance_setLoopInPoint(so_in, 44100); // We ask not to start this if previous is still going, // so if outPoint didn't work it's easly to detect SWFSoundInstance_setNoMultiple(so_in); printFrameInfo(mo, 1, "Two notes (E, G)"); SWFMovie_nextFrame(mo); (*frame)++; // inPoint + outPoint + loop so_in = SWFMovie_startSound(mo, so); SWFSoundInstance_setLoopInPoint(so_in, 44100); SWFSoundInstance_setLoopOutPoint(so_in, 44100*2); SWFSoundInstance_setLoopCount(so_in, 2); printFrameInfo(mo, 2, "One note (E)"); SWFMovie_nextFrame(mo); (*frame)++; printFrameInfo(mo, 3, "One note (E)"); SWFMovie_nextFrame(mo); (*frame)++; printFrameInfo(mo, 4, "Nothing"); SWFMovie_nextFrame(mo); (*frame)++; }
int main() { SWFMovie m = newSWFMovieWithVersion(7); SWFSound sound; SWFSoundStream stream; FILE *file; int ret; file = fopen(MEDIADIR "/audio01.mp3", "rb"); if(!file) { perror(MEDIADIR "/audio01.mp3"); return EXIT_FAILURE; } stream = newSWFSoundStream(file); if (!stream) { fprintf(stderr, "Could not create SWFSoundStream\n"); return EXIT_FAILURE; } sound = newSWFSound_fromSoundStream(stream); if(!sound) { fprintf(stderr, "Could not create SWFSound\n"); return EXIT_FAILURE; } SWFMovie_addExport(m, sound, "audio01.mp3"); SWFMovie_startSound(m, sound); ret = SWFMovie_save(m, "test01.swf"); if ( ret == -1 ) { fprintf(stderr, "Something went wrong during SWFMovie_save\n"); return EXIT_FAILURE; } //SWFSoundStream destroy SWFInput created from file destroySWFSoundStream(stream); destroySWFSound(sound); destroySWFMovie(m); return 0; }
void runNoMultipleSoundsTest(SWFMovie mo, SWFSound so, int* frame) { const char* frameDesc[5]; int i; SWFMovie_nextFrame(mo); add_actions(mo, "note('\nNon-multiple Sound Test\n" "The notes should start exactly at the beginning " "of a frame (to coincide with the appearance of the description " "text)');"); /* This is what is supposed to happen in each frame */ frameDesc[0] = "Two notes (C, E)"; frameDesc[1] = "One note (G)"; frameDesc[2] = "Two notes (C, E) "; frameDesc[3] = "One note (G)"; frameDesc[4] = "Nothing"; for (i = 0; i < 4; i++) { printFrameInfo(mo, i, frameDesc[i]); SWFSoundInstance so_in = SWFMovie_startSound(mo, so); SWFSoundInstance_setNoMultiple(so_in); SWFMovie_nextFrame(mo); (*frame)++; } //SWFMovie_nextFrame(mo); printFrameInfo(mo, i, frameDesc[i]); SWFMovie_stopSound(mo, so); }
void runAttachedSoundsTest(SWFMovie mo, SWFSound so, int* frame) { const char* frameDesc[5]; int i; SWFMovie_nextFrame(mo); add_actions(mo, "note('\nAttached Embedded Sound Test.\n" "The notes should start exactly at the beginning of a frame " "(to coincide with the appearance of the description text).\n" "Test should start in two seconds.');"); /* This is what is supposed to happen in each frame */ frameDesc[0] = "Two notes (C, E)"; frameDesc[1] = "Two notes (G-C, E)"; frameDesc[2] = "Two notes (G-C, E)"; frameDesc[3] = "Two notes (G-C, E)"; frameDesc[4] = "Nothing"; add_actions(mo, "t = _root.createEmptyMovieClip('mc', 9);" "cs = 0; cs2 = 0;" "s = new Sound(mc);" "s2 = new Sound(mc);" "s.attachSound('es');" "s2.attachSound('es');" "s.onSoundComplete = function() { cs++; };" "s2.onSoundComplete = function() { cs2++; };" ); /// Start an embedded sound using a tag to make sure onSoundComplete /// isn't called for Sound s. SWFMovie_startSound(mo, so); /// Start the same embedded sound from another Sound object also to /// make sure the correct object is notified. add_actions(mo, "s2.start(); delete s2;"); printFrameInfo(mo, 0, frameDesc[0]); for (i = 1; i < 4; i++) { SWFMovie_nextFrame(mo); (*frame)++; printFrameInfo(mo, i, frameDesc[i]); add_actions(mo, "s.start();"); } add_actions(mo, "xcheck_equals(cs, 1);"); SWFMovie_nextFrame(mo); add_actions(mo, "xcheck_equals(cs, 2);"); // Check that Sound.onSoundComplete isn't executed if the Sound is // deleted. This only passes currently because onSoundComplete is never // called under any circumstances for embedded sounds. add_actions(mo, "check_equals(cs2, 0);"); add_actions(mo, "s.stop();"); printFrameInfo(mo, i, frameDesc[i]); }
EXPORT BOOL WINAPI m_startSound(SWFDisplayItem item, int p2, int p3, int p4) { lstrcpy(funcname, "m_startSound"); SWFMovie_startSound(mhsp_movie, item); return 0; }