Re: Embedding mp3

Darren Cook <[email protected]> Tue, 30 Dec 2003 16:52:45 +0900
Newsgroups gmane.comp.web.ming.general
Message-ID <[email protected]>
>>I'd like to embed a few mp3 files in a swf (as opposed
>> to streaming mp3).

Dave wrote:
> You can do it like this using the 0.3a CVS version.

Belated thanks for the replies. I've got Ming properly installed now and
managed to run the examples using PHP. The numbers don't appear by the way
(I tried a few variations on _root.status=... but no luck yet).

More importantly to me, this example does not embed the mp3: the produced
file is only  267 bytes, and if I delete the mp3 file after compiling it
fails to play anything.

In contrast when I do this with the Flash authoring tool, with the same mp3
file, I get a 133Kb swf file. Is it possible to do the same with Ming?

Darren


> <?
>   Ming_setScale(1.0);
>   Ming_useSWFVersion(6);
> 
>   $mp3URL = 'distortobass.mp3';
> 
>   $f = new SWFFont("Arial.fdb");
> 
>   $m = new SWFMovie();
>   $m->setDimension(20,20);
>   $m->setBackground(0xff, 0xff, 0xff);
> 
>   $t = new SWFTextField(SWFTEXTFIELD_NOEDIT | SWFTEXTFIELD_NOSELECT );
>   $t->setName("statusTxt");
>   $t->setFont($f);
>   $t->setColor(0x00, 0x00, 0x00);
>   $t->setHeight(12);
>   $t->addString('1');
>   $xt = $m->add($t);
>   $xt->setDepth(10);
>   $xt->setName('status');
>   $xt->moveTo(1,1);
> 
>   $m->add(new SWFAction("
>     var loops = 1;
>     sndClip1=new Sound();
>     sndClip1.loadSound('$mp3URL',true);
>     sndClip1.setVolume(100);
>     sndClip1.start();
>     sndClip1.onSoundComplete = function () {
>       sndClip1.start();
>       loops +=1;
>       _root.statusTxt = loops;
>     };
>   "));
> 
>   $m->save("streammp3mx.swf",9);
> 
>   //header('Content-type: application/x-shockwave-flash');
>   //$m->output(9); //Compression Level 0...9
> ?>