示例#1
0
void
addSoundExport(SWFMovie mo)
{
    SWFSound soundMP3a;
    SWFSound soundMP3b;
    SWFSound soundMP3c;
    SWFSound soundMP3d;

    FILE* f;
    FILE* f2;

    f = fopen(MEDIADIR"/mono44.mp2", "r");

    if (!f)
    {
	perror(MEDIADIR"/mono44.mp2");
        exit(EXIT_FAILURE);
    }
    soundMP3a = newSWFSound(f, SWF_SOUND_MP3_COMPRESSED |
            SWF_SOUND_44KHZ |
            SWF_SOUND_16BITS |
            SWF_SOUND_MONO);
    
    soundMP3b = newSWFSound(f, SWF_SOUND_MP3_COMPRESSED |
            SWF_SOUND_22KHZ |
            SWF_SOUND_16BITS |
            SWF_SOUND_STEREO);


    f2 = fopen(MEDIADIR"/stereo8.mp3", "r");
    if (f2 == NULL)
    {
	perror(MEDIADIR"/stereo8.mp3");
        exit(EXIT_FAILURE);
    }

    soundMP3c = newSWFSound(f2, SWF_SOUND_MP3_COMPRESSED |
            SWF_SOUND_44KHZ |
            SWF_SOUND_16BITS |
            SWF_SOUND_MONO);
    
    soundMP3d = newSWFSound(f2, SWF_SOUND_MP3_COMPRESSED |
            SWF_SOUND_5KHZ |
            SWF_SOUND_16BITS |
            SWF_SOUND_STEREO);

    SWFMovie_addExport(mo, (SWFBlock)soundMP3a, "mono22_mp2");
    SWFMovie_addExport(mo, (SWFBlock)soundMP3b, "mono22_mp2b");
    SWFMovie_addExport(mo, (SWFBlock)soundMP3c, "stereo8_mp3");
    SWFMovie_addExport(mo, (SWFBlock)soundMP3d, "stereo8_mp3b");

    SWFMovie_writeExports(mo);
}
示例#2
0
文件: test01.c 项目: akleine/libming
int main()
{
	SWFMovie m = newSWFMovieWithVersion(8);
	SWFDBLBitmapData img = newSWFDBLBitmapData_fromPngFile(MEDIADIR "/image01.png");
	if(img == NULL)
		return EXIT_FAILURE;

	SWFMovie_addExport(m, (SWFBlock)img, "BitmapExport");
	SWFMovie_writeExports(m);
	
	SWFMovie_save(m, "test01.swf");
	return 0;

}
示例#3
0
文件: test03.c 项目: akleine/libming
int main()
{
	SWFMovieClip mc;
	SWFMovie m;
	SWFAction a;

	m = newSWFMovie();
	a = newSWFAction("trace('');");
	mc = newSWFMovieClip();

	SWFMovieClip_addInitAction(mc, a);
	SWFMovie_addExport(m, mc, "test");
	SWFMovie_add(m, mc);	
	SWFMovie_save(m, "test03.swf");
	return 0;
}
示例#4
0
void
addRedSquareExport(SWFMovie mo)
{
	SWFShape sh;
	SWFMovieClip mc;

	sh = make_fill_square (0, 0, 60, 60, 255, 0, 0, 255, 0, 0);
	mc = newSWFMovieClip();

	SWFMovieClip_add(mc, (SWFBlock)sh);
	/* This is here just to turn the clip into an active one */
	add_clip_actions(mc, "onRollOver = function() {};");
	SWFMovieClip_nextFrame(mc);

	SWFMovie_addExport(mo, (SWFBlock)mc, "redsquare");

	SWFMovie_writeExports(mo);
}
示例#5
0
文件: test01.c 项目: akleine/libming
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;
}
示例#6
0
int main(int argc, char* argv[])
{

    SWFMovie mo;
    SWFMovieClip mc1, mc2, mc3, mc4, dejagnuclip;
    SWFDisplayItem it;
    SWFAction ac;
    SWFInitAction initac;

    const char *srcdir=".";
    if (argc > 1) srcdir = argv[1];
    else {
        fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
        return 1;
    }

    Ming_init();
    mo = newSWFMovieWithVersion(OUTPUT_VERSION);
    SWFMovie_setDimension(mo, 800, 600);
    SWFMovie_setRate (mo, 12.0);

    add_actions(mo,
            "if (!_global.hasOwnProperty('arr')) { _global.arr = []; };"
            "_global.ch = function(a, b) {"
            "   trace(a);"
            "   if (typeof(b)=='undefined' || (typeof(b)=='boolean' && b)) {"
            "       _global.arr.push(a);"
            "   };"
            "};"
            "this.onEnterFrame = function() { "
            "   _global.ch('onEnterFrame', false);"
            "};"
            );

    SWFMovie_nextFrame(mo);

    //  MovieClip 1 
    mc1 = newSWFMovieClip(); // 1 frames 

    // SWF_EXPORTASSETS 
    SWFMovie_addExport(mo, (SWFBlock)mc1, "Segments_Name");
    SWFMovie_writeExports(mo);

    //  MovieClip mc3 has two frames. In each frame a different MovieClip
    //  is placed with the name Segments.
    mc3 = newSWFMovieClip(); // 2 frames 

    //  MovieClip 2 
    mc2 = newSWFMovieClip(); // 1 frames 

    // Add mc2
    it = SWFMovieClip_add(mc3, (SWFBlock)mc2);
    SWFDisplayItem_setDepth(it, 1);
    SWFDisplayItem_setName(it, "Segments");

    // Frame 2
    SWFMovieClip_nextFrame(mc3);

    // Remove mc2
    SWFDisplayItem_remove(it);

    // Add mc1
    it = SWFMovieClip_add(mc3, (SWFBlock)mc1);
    SWFDisplayItem_setDepth(it, 1);
    SWFDisplayItem_setName(it, "Segments");

    SWFMovieClip_nextFrame(mc3);

    // End mc3


    // This is frame 1 of the main timeline

    // Put our sprite mc3 on stage.
    it = SWFMovie_add(mo, (SWFBlock)mc3);
    SWFDisplayItem_setDepth(it, 1);
    SWFDisplayItem_setName(it, "mc");

    //  mc4 is just for executing init actions.
    mc4 = newSWFMovieClip(); 
    SWFMovie_addExport(mo, (SWFBlock)mc4, "__Packages.Bug");
    SWFMovie_writeExports(mo);
    
    dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10,
                0, 0, 800, 600);
    SWFMovie_add(mo, (SWFBlock)dejagnuclip);

    ac = newSWFAction(
        "_global.loops = 0;"
        "_global.c = 0;"
        "if( !_global.Bug ) {"
        "   _global.Bug = function () {"
        "       this.onUnload = function() { "
        "           _global.ch('dynamic unload: ' + this.c);"
        "       }; "
        "       this.onLoad = function() { "
        "           _global.ch('dynamic load: ' + this.c);"
        "       }; "
        "       this.c = _global.c;"
        "       _global.ch('ctor: ' + _global.c);"
        "       _global.c++;"
        "   };"
        "};"
    );

    initac = newSWFInitAction_withId(ac, 4);
    SWFMovie_add(mo, (SWFBlock)initac);
    
    ac = newSWFAction("Object.registerClass('Segments_Name',Bug);");
    initac = newSWFInitAction_withId(ac, 1);
    SWFMovie_add(mo, (SWFBlock)initac);
    add_actions(mo, "_global.ch('Frame ' + "
                            "_level0._currentframe + ' actions: ' "
                            "+ _level0.mc.Segments.c);");

    // Frame 2 of the main timeline
    SWFMovie_nextFrame(mo);
    add_actions(mo, "_global.ch('Frame ' + "
                            "_level0._currentframe + ' actions: ' "
                            "+ _level0.mc.Segments.c);");
    
    add_actions(mo,
        "    if (_global.loops < 5) {"
        "        _global.loops++;"
        "        gotoAndPlay(2);"
        "   }"
        "   else {"
        "      delete this.onEnterFrame;"
        "      gotoAndPlay(4);"
        "   };"
        );
    
    SWFMovie_nextFrame(mo);
    
    check_equals(mo, "_global.arr.length", "20");
    check_equals(mo, "_global.arr[0]", "'Frame 2 actions: undefined'");
    check_equals(mo, "_global.arr[1]", "'ctor: 0'");
    xcheck_equals(mo, "_global.arr[2]", "'Frame 3 actions: 0'");
    xcheck_equals(mo, "_global.arr[3]", "'dynamic load: 0'");
    check_equals(mo, "_global.arr[4]", "'Frame 2 actions: 0'");
    check_equals(mo, "_global.arr[5]", "'Frame 3 actions: 0'");
    check_equals(mo, "_global.arr[6]", "'Frame 2 actions: 0'");
    check_equals(mo, "_global.arr[7]", "'ctor: 1'");
    check_equals(mo, "_global.arr[8]", "'dynamic unload: 0'");
    xcheck_equals(mo, "_global.arr[9]", "'Frame 3 actions: 0'");
    check_equals(mo, "_global.arr[11]", "'Frame 2 actions: 0'");
    check_equals(mo, "_global.arr[12]", "'Frame 3 actions: 1'");
    check_equals(mo, "_global.arr[13]", "'Frame 2 actions: 1'");
    check_equals(mo, "_global.arr[14]", "'ctor: 2'");
    check_equals(mo, "_global.arr[15]", "'dynamic unload: 1'");
    xcheck_equals(mo, "_global.arr[16]", "'Frame 3 actions: 1'");
    xcheck_equals(mo, "_global.arr[17]", "'dynamic load: 2'");
    check_equals(mo, "_global.arr[18]", "'Frame 2 actions: 1'");
    check_equals(mo, "_global.arr[19]", "'Frame 3 actions: 2'");
    xcheck_equals(mo, "_global.arr.toString()",
		    "'Frame 2 actions: undefined,ctor: 0,Frame 3 actions: 0,dynamic load: 0,Frame 2 actions: 0,Frame 3 actions: 0,Frame 2 actions: 0,ctor: 1,dynamic unload: 0,Frame 3 actions: 0,dynamic load: 1,Frame 2 actions: 0,Frame 3 actions: 1,Frame 2 actions: 1,ctor: 2,dynamic unload: 1,Frame 3 actions: 1,dynamic load: 2,Frame 2 actions: 1,Frame 3 actions: 2'");

    SWFMovie_nextFrame(mo);
    add_actions(mo, "totals(21); stop();");
    
    SWFMovie_nextFrame(mo);

    // SWF_END 
    SWFMovie_save(mo, OUTPUT_FILENAME);

    return 0;
}
示例#7
0
int
main(int argc, char** argv)
{
  SWFMovie mo;
  SWFSound so;
  const char* soundFile;
  const char* srcdir;
  int frame;

  if (argc > 1) {
    soundFile = argv[1];
  }
  else {
    soundFile = "brokenchord.wav";
  }
  if (argc > 2) {
    srcdir = argv[2];
  }
  else {
    srcdir = ".";
  }

  /* setup ming and basic movie properties */
  Ming_init();  
  Ming_useSWFVersion(OUTPUT_VERSION);

  mo = newSWFMovie();
  SWFMovie_setDimension(mo, 800, 600);
  SWFMovie_setRate(mo, 0.5);

  setupMovie(mo, srcdir);
  so = setupSounds(soundFile);
  
  /// Add as an export so we can attach it.
  SWFMovie_addExport(mo, (SWFBlock)so, "es");
  SWFMovie_writeExports(mo);

  add_actions(mo, "c = 0;");

  SWFMovie_nextFrame(mo);

  add_actions(mo,
       "note('You will hear several short tests with a succession of sounds. "
       "Each frame is two seconds long.\n"
       "The movie will describe what you should hear at the beginning of "
       "the frame.');");
		  
  frame = 0;

  pauseForNextTest(mo);
  runMultipleSoundsTest(mo, so, &frame);
  
  pauseForNextTest(mo);
  runNoMultipleSoundsTest(mo, so, &frame);

  pauseForNextTest(mo);
  runTrimmedSoundsTest(mo, so, &frame);

  pauseForNextTest(mo);
  runAttachedSoundsTest(mo, so, &frame);

  // TODO: test start(<sec_offset>) (+ with loop ?)

  endOfTests(mo);

  //Output movie
  puts("Saving " OUTPUT_FILENAME );
  SWFMovie_save(mo, OUTPUT_FILENAME);

  return 0;
}
示例#8
0
int
main(int argc, char** argv)
{
    SWFMovie mo;
    SWFMovieClip mc3, mc2, dejagnuclip;
    SWFAction ac, ac1, initac;
    SWFDisplayItem it;
    SWFShape sha;

    const char *srcdir=".";
    if (argc > 1) srcdir = argv[1];
    else {
        fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
        return 1;
    }

    Ming_init();
    mo = newSWFMovieWithVersion(OUTPUT_VERSION);
    SWFMovie_setDimension(mo, 800, 600);
    SWFMovie_setRate (mo, 12.0);


    sha = newSWFShape();

    // Character ID 2. Has 1 showframe. Is exported first.
    mc2 = newSWFMovieClip();
    SWFMovieClip_add(mc2, (SWFBlock)sha);
    SWFMovieClip_nextFrame(mc2);

    // Export it.
    SWFMovie_addExport(mo, (SWFBlock)mc2, "C2");
    SWFMovie_writeExports(mo);

    // Main timeline actions for frame 1
    add_actions(mo, "var c = 0; var i = 0; trace('frame 1'); gotoAndStop(3);");
    initac = newSWFAction("trace('onInitialize'); _root.i++;");
    
    // ID 3 is defined here. It has no showframe. It is exported immediately.
    mc3 = newSWFMovieClip();
    SWFMovie_addExport(mo, (SWFBlock)mc3, "ctor");
    SWFMovie_writeExports(mo);

    dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10,
    		    0, 0, 800, 600);
    SWFMovie_add(mo, (SWFBlock)dejagnuclip);

    // Init actions for ID 3. This only exists to create the constructor
    // for mc2 in its initactions.
    ac = newSWFAction(
    "   _global.ctor = function () {"
    "       super();"
    "       trace('Object ID 2 is constructed');"
    "       c += 1;"
    "   };"
    );
    SWFInitAction ia = newSWFInitAction_withId(ac, 3);
    SWFMovie_add(mo, (SWFBlock)ia);
    
    // Init actions for ID 2 (registered class)
    ac1 = newSWFAction("Object.registerClass('C2', ctor); "
            "trace('Registered class');");
    ia = newSWFInitAction_withId(ac1, 2);
    SWFMovie_add(mo, (SWFBlock)ia);
	
    
    // Frame 2
    SWFMovie_nextFrame(mo);
    add_actions(mo, "trace('Frame 2');");
    
    // Place object ID 2.
    it = SWFMovie_add(mo, (SWFBlock)mc2);
    SWFDisplayItem_setName(it, "mc2");
    SWFDisplayItem_addAction(it, initac, SWFACTION_INIT);

    // Frame 3
    SWFMovie_nextFrame(mo);

    // Remove object ID 2
    SWFMovie_remove(mo, it);

    add_actions(mo, "trace('frame 3');");
    
    // The class should not be constructed if the object is removed after
    // being placed. It should be constructed if it's not removed. MovieClips
    // with an onUnload handler are always constructed.
    check_equals(mo, "c", "0");
    check_equals(mo, "i", "0");
    check(mo, "_root.mc2 == undefined");
    add_actions(mo, "gotoAndPlay(5);");

    // Frame 4
    SWFMovie_nextFrame(mo);
    add_actions(mo, "trace('Frame 4');");
    
    // Place object ID 2 again
    it = SWFMovie_add(mo, (SWFBlock)mc2);
    SWFDisplayItem_setName(it, "mc2a");
    SWFDisplayItem_addAction(it, initac, SWFACTION_INIT);

    // Frame 5
    SWFMovie_nextFrame(mo);

    // This time the MovieClip was not removed before we get here,
    // so it should be present and the constructor should be
    // called.
    add_actions(mo, "trace('frame 5');");
    check_equals(mo, "c", "1");
    check_equals(mo, "i", "1");
    check(mo, "typeof(_root.mc2a) == 'movieclip'");
    add_actions(mo, "stop();");

    SWFMovie_nextFrame(mo);
  
    puts("Saving " OUTPUT_FILENAME );
    SWFMovie_save(mo, OUTPUT_FILENAME);

    return 0;
}
示例#9
0
文件: minghsp.c 项目: tkhaga/MingHSP
EXPORT BOOL WINAPI m_addExport(SWFBlock block, char *name, int p3, int p4)
{
	lstrcpy(funcname, "m_addExport");
	SWFMovie_addExport(mhsp_movie, block, name);
	return 0;
}
示例#10
0
文件: Dejagnu.c 项目: aopui/gnash
int
main(int argc, char** argv)
{
	SWFMovie mo;
	SWFMovieClip dejaclip;
	const char *srcdir=".";
	SWFFont bfont; 


	/*********************************************
	 *
	 * Initialization
	 *
	 *********************************************/

	if ( argc>1 ) srcdir=argv[1];
	else
	{
		fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
		return 1;
	}

	puts("Setting things up");

	Ming_init();
        Ming_useSWFVersion (OUTPUT_VERSION);
	Ming_setScale(20.0); /* let's talk pixels */
 
	mo = newSWFMovie();
	SWFMovie_setRate(mo, 1);
	SWFMovie_setDimension(mo, 628, 1024);

	bfont = get_default_font(srcdir);

	/*********************************************
	 *
	 * Body
	 *
	 *********************************************/

	dejaclip = get_dejagnu_clip((SWFBlock)bfont, 3000, 0, 50, 800, 800);

	SWFMovie_add(mo, (SWFBlock)dejaclip);
	SWFMovie_addExport(mo, (SWFBlock)dejaclip, "dejagnu");
	SWFMovie_addExport(mo, (SWFBlock)SWFMovie_addFont(mo, bfont),
		"dejafont");

	SWFMovie_nextFrame(mo); /* showFrame */


	/*****************************************************
	 *
	 * Output movie
	 *
	 *****************************************************/

	puts("Saving " OUTPUT_FILENAME );

	SWFMovie_save(mo, OUTPUT_FILENAME);

	return 0;
}