Embed mp3 in actionscript 3 doesn't work

这一生的挚爱 提交于 2019-12-19 17:39:31

问题


I have a problem with actionscript 3, especially when using the embed tag. I have this code:

[Embed(source = "sound.mp3")]
private static var soundClip:Class;

...

var sound:Sound = (new soundClip()) as Sound;
trace(sound.length);

When I test the movie, I get the following output : 4501,923 Which is the sound.mp3 length in milliseconds. However, the original sound is 13.000 milliseconds.

How can that be possible, can anyone help me please?

Thank you.


回答1:


The Embed process implies a transcodification (made by the compiler), if the sound doesn't fit into the supported Flash Player Sound format you can get unexpected results, like shrunk length. Check that the sounds you embed is at 44100 Hz Stereo, that is the supported sampling rate that won't cause any issues.

Cheers!




回答2:


your audio might have trouble being transcoded due to its sampling rate. a good standard is 44100Hz, but I've had 11025Hz work perfectly fine as well. you can easily change the sampling rate in seconds on nearly any audio file through Audacity, which is free and fairly powerful, but hardly intuitive.




回答3:


I don't think you can load the MP3 just like that, you need to put it into a SWF first, then load the SWF, then instance the sound. Look here and here.



来源:https://stackoverflow.com/questions/6818257/embed-mp3-in-actionscript-3-doesnt-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!