2
* Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 3 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
#include "ming_utils.h"
26
#define OUTPUT_VERSION 8
27
#define OUTPUT_FILENAME "EmbeddedSoundTest.swf"
29
void addSoundExport(SWFMovie mo);
32
addSoundExport(SWFMovie mo)
42
f = fopen(MEDIADIR"/mono44.mp2", "r");
48
soundMP3a = newSWFSound(f, SWF_SOUND_MP3_COMPRESSED |
53
soundMP3b = newSWFSound(f, SWF_SOUND_MP3_COMPRESSED |
59
f2 = fopen(MEDIADIR"/stereo8.mp3", "r");
65
soundMP3c = newSWFSound(f2, SWF_SOUND_MP3_COMPRESSED |
70
soundMP3d = newSWFSound(f2, SWF_SOUND_MP3_COMPRESSED |
75
SWFMovie_addExport(mo, (SWFSound)soundMP3a, "mono22_mp2");
76
SWFMovie_addExport(mo, (SWFSound)soundMP3b, "mono22_mp2b");
77
SWFMovie_addExport(mo, (SWFSound)soundMP3c, "stereo8_mp3");
78
SWFMovie_addExport(mo, (SWFSound)soundMP3d, "stereo8_mp3b");
80
SWFMovie_writeExports(mo);
84
main(int argc, char** argv)
87
const char *srcdir=".";
88
SWFMovieClip dejagnuclip;
91
/*********************************************
95
*********************************************/
97
if ( argc>1 ) srcdir=argv[1];
100
fprintf(stderr, "Usage: %s\n", argv[0]);
104
puts("Setting things up");
107
Ming_useSWFVersion (OUTPUT_VERSION);
108
Ming_setScale(20.0); /* let's talk pixels */
111
SWFMovie_setRate(mo, 1.33);
112
SWFMovie_setDimension(mo, 640, 400);
114
/*********************************************
118
*********************************************/
120
dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 80, 800, 600);
121
SWFMovie_add(mo, (SWFBlock)dejagnuclip);
124
SWFMovie_nextFrame(mo); /* end of frame1 */
126
// Tracker variables for calls to onSoundComplete
127
add_actions(mo, "c_soundComplete = 0;");
128
add_actions(mo, "d_soundComplete = 0;");
129
add_actions(mo, "e_soundComplete = 0;");
131
add_actions(mo, "a = new Sound(); a.attachSound('mono22_mp2');");
132
add_actions(mo, "b = new Sound(); b.attachSound('mono22_mp2b');");
133
add_actions(mo, "c = new Sound(); c.attachSound('stereo8_mp3');");
135
// Two different Sounds with the same exported sound.
136
add_actions(mo, "d = new Sound(); d.attachSound('stereo8_mp3b');");
137
add_actions(mo, "e = new Sound(); e.attachSound('stereo8_mp3b');");
139
check_equals(mo, "a.duration", "13740");
140
add_actions(mo, "check_equals(a.getBytesTotal(), undefined);");
141
add_actions(mo, "check_equals(a.getBytesLoaded(), undefined);");
142
add_actions(mo, "check_equals(a.id3, undefined);");
143
check_equals(mo, "a.position", "0");
144
add_actions(mo, "a.start();");
145
// This isn't very consistent either. Please re-enable when it is.
146
//check_equals(mo, "a.position", "0");
148
check_equals(mo, "b.duration", "13740");
149
check_equals(mo, "b.position", "0");
150
add_actions(mo, "b.start();");
152
// Here, gst gives 46, ffmpeg 0.
153
//check_equals(mo, "b.position", "0");
155
check_equals(mo, "c.duration", "5224");
156
check_equals(mo, "c.position", "0");
157
// Play twice (loop).
158
add_actions(mo, "c.start(0, 2);");
159
check_equals(mo, "c.position", "0");
161
check_equals(mo, "d.duration", "5224");
162
check_equals(mo, "d.position", "0");
164
add_actions(mo, "d.start();");
165
add_actions(mo, "d.start(4);");
166
check_equals(mo, "d.position", "0");
168
add_actions(mo, "e.start();");
170
SWFMovie_nextFrame(mo);
172
add_actions(mo, "stop();"
173
"note('will wait for onSoundComplete to finish the test (about "
176
// This is the longest sound, so the test should end when this is called.
177
add_actions(mo, "a.onSoundComplete = function() {"
178
"check_equals(a.position, 13740);"
179
"check_equals(c_soundComplete, 1);"
180
"check_equals(d_soundComplete, 1);"
181
"check_equals(e_soundComplete, 2);"
186
// Check position of b, c, d, and e after the first loop of c.
187
add_actions(mo, "c.onSoundComplete = function() {"
188
// I'm not sure how reliable this is:
189
"check_equals(b.position, 10472);"
190
"check_equals(c.position, 5224);"
191
"check_equals(d.position, 5224);"
192
"check_equals(e.position, 5224);"
194
"note('c.onSoundComplete() called '+c_soundComplete+' time(s).');"
197
add_actions(mo, "d.onSoundComplete = function() {"
198
"check_equals(d.position, 5224);"
200
"note('d.onSoundComplete() called '+d_soundComplete+' time(s).');"
203
// This starts e again. It should run twice before the longest
205
add_actions(mo, "e.onSoundComplete = function() {"
206
"check_equals(e.position, 5224);"
208
"note('e.onSoundComplete() called '+e_soundComplete+' time(s).');"
213
/*****************************************************
217
*****************************************************/
219
puts("Saving " OUTPUT_FILENAME );
221
SWFMovie_save(mo, OUTPUT_FILENAME);