EXPORT BOOL WINAPI m_streamMp3(void *p1, char *mp3FileName, int p3, int p4) { FILE *fp = fopen(mp3FileName, "rb"); if (!fp) { return 1; } lstrcpy(funcname, "m_streamMp3"); SWFMovie_setSoundStream(mhsp_movie, newSWFSoundStream(fp)); return 0; }
EXPORT BOOL WINAPI m_streamMp3(void *p1, char *mp3FileName, float skip, int p4) { FILE *fp = fopen(mp3FileName, "rb"); SWFSoundStream sound; if (!fp) { return 1; } lstrcpy(funcname, "m_streamMp3"); sound = newSWFSoundStream(fp); SWFMovie_setSoundStreamAt(mhsp_movie, sound, skip); return -SWFSoundStream_getFrames(sound); }
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; }
int main() { SWFMovie m; SWFMovieClip mc; SWFSoundStream stream; FILE* file; file = fopen(MEDIADIR "/sound1.mp3", "rb"); if(!file) { perror(MEDIADIR "/sound1.mp3"); return EXIT_FAILURE; } m = newSWFMovieWithVersion(7); SWFMovie_setRate(m, 1); stream = newSWFSoundStream(file); if(stream == NULL) { fprintf(stderr, "SoundStream failed\n"); return EXIT_FAILURE; } mc = newSWFMovieClip(); SWFMovieClip_setSoundStream(mc, stream, 1); SWFMovieClip_nextFrame(mc); SWFMovieClip_nextFrame(mc); SWFMovie_add(m, mc); SWFMovie_nextFrame(m); SWFMovie_save(m, "test01.swf"); fclose(file); return EXIT_SUCCESS; }
int main(int argc, char** argv) { SWFMovie mo; SWFMovieClip mc; SWFSoundStream ss; FILE* sound_f; const char* sound_filename; SWFDisplayItem it; struct stat statbuf; if ( argc>1 ) { sound_filename=argv[1]; } else { sound_filename="sound1.mp3"; } sound_f = fopen(sound_filename, "r"); if ( ! sound_f ) { perror(sound_filename); return EXIT_FAILURE; } printf("Using sound file %s\n", sound_filename); if ( -1 == fstat(fileno(sound_f), &statbuf) ) { perror("fstat"); return EXIT_FAILURE; } if ( S_ISDIR(statbuf.st_mode) ) { fprintf(stderr, "%s is a directory, we need a file\n", sound_filename); return EXIT_FAILURE; } Ming_init(); Ming_useSWFVersion (OUTPUT_VERSION); mo = newSWFMovie(); SWFMovie_setDimension(mo, 100, 100); SWFMovie_setRate(mo, 1); ss = newSWFSoundStream(sound_f); mc = newSWFMovieClip(); SWFMovieClip_setSoundStream(mc, ss, 1); SWFMovieClip_nextFrame(mc); it = SWFMovie_add(mo, mc); SWFMovie_nextFrame(mo); SWFMovie_nextFrame(mo); SWFMovie_nextFrame(mo); SWFMovie_nextFrame(mo); SWFMovie_nextFrame(mo); SWFMovie_nextFrame(mo); SWFMovie_nextFrame(mo); SWFMovie_nextFrame(mo); //Output movie puts("Saving " OUTPUT_FILENAME ); SWFMovie_save(mo, OUTPUT_FILENAME); return EXIT_SUCCESS; }
gboolean swf_add_mouse_click(SWFMovie this_movie, gint click_type) { // Local variables gfloat click_duration; guint click_frames; GString *click_name; // The name of the mouse click sound we'll need to play guint i; // Counter GString *message; // Used to construct message strings SWFDisplayItem sound_display_item; FILE *sound_file; // The file we load the sound from SWFMovieClip sound_movie_clip; // Movie clip specifically to hold a sound SWFSoundStream sound_stream; // The sound we use gets loaded into this gchar *sound_pathname = NULL; // Full pathname to a sound file to load is constructed in this SWFAction swf_action; // Used when constructing action script // Initialisation click_name = g_string_new(NULL); // Determine the sound file to load switch (click_type) { case MOUSE_LEFT_ONE: case MOUSE_RIGHT_ONE: case MOUSE_MIDDLE_ONE: // If we've already added the sound to the movie, we don't need to add it again if (FALSE == get_mouse_click_single_added()) { // Single click mouse sound sound_pathname = g_build_path(G_DIR_SEPARATOR_S, SOUND_DIR, "mouse_single_click.mp3", NULL); // Make sure we only add this click sound once set_mouse_click_single_added(TRUE); } click_name = g_string_assign(click_name, "mousesingleclick"); click_duration = 0.5; break; case MOUSE_LEFT_DOUBLE: case MOUSE_RIGHT_DOUBLE: case MOUSE_MIDDLE_DOUBLE: // If we've already added the sound to the movie, we don't need to add it again if (FALSE == get_mouse_click_double_added()) { // Double click mouse sound sound_pathname = g_build_path(G_DIR_SEPARATOR_S, SOUND_DIR, "mouse_double_click.mp3", NULL); // Make sure we only add this click sound once set_mouse_click_double_added(TRUE); } click_name = g_string_assign(click_name, "mousedoubleclick"); click_duration = 0.5; break; case MOUSE_LEFT_TRIPLE: case MOUSE_RIGHT_TRIPLE: case MOUSE_MIDDLE_TRIPLE: // If we've already added the sound to the movie, we don't need to add it again if (FALSE == get_mouse_click_triple_added()) { // Triple click mouse sound sound_pathname = g_build_path(G_DIR_SEPARATOR_S, SOUND_DIR, "mouse_triple_click.mp3", NULL); // Make sure we only add this click sound once set_mouse_click_triple_added(TRUE); } click_name = g_string_assign(click_name, "mousetripleclick"); click_duration = 0.5; break; } if (NULL != sound_pathname) { // Create the sound object we'll be using if (get_debug_level()) printf("%s: '%s'\n", _("Full path name to sound file is"), sound_pathname); // Load the sound file sound_file = fopen(sound_pathname, "rb"); if (NULL == sound_file) { // Something went wrong when loading the sound file, so return message = g_string_new(NULL); g_string_printf(message, "%s ED412: %s", _("Error"), _("Something went wrong when opening a mouse click sound file.")); display_warning(message->str); g_string_free(message, TRUE); return FALSE; } sound_stream = newSWFSoundStream(sound_file); // Create a new movie clip file, containing only the sound sound_movie_clip = newSWFMovieClip(); // Ensure the clip doesn't start out playing nor keep looping swf_action = compileSWFActionCode("this.stop(); "); SWFMovieClip_add(sound_movie_clip, (SWFBlock) swf_action); SWFMovieClip_nextFrame(sound_movie_clip); // Add the sound stream to the sound movie clip SWFMovieClip_setSoundStream(sound_movie_clip, sound_stream, 1); SWFMovieClip_nextFrame(sound_movie_clip); // Add extra frames to allow the click to play it's full length click_frames = roundf(click_duration * get_frames_per_second()); for (i = 0; i < click_frames; i++) { SWFMovieClip_nextFrame(sound_movie_clip); } // Add the sound movie clip to the swf movie sound_display_item = SWFMovie_add(this_movie, (SWFBlock) sound_movie_clip); // Name the display item SWFDisplayItem_setName(sound_display_item, click_name->str); // Ensure the object is at the correct display depth SWFDisplayItem_setDepth(sound_display_item, 1000 + click_type); // Trying to pick a non conflicting depth } // Free the memory allocated in this functions g_string_free(click_name, TRUE); return TRUE; }
SWFSoundStream newSWFSoundStreamFromFileno(int fd) { FILE *fp = fdopen(fd, "r"); return newSWFSoundStream(fp); }