Raj*_*eev 4 apache-flex mxml actionscript-3 mxmlc
我需要的动作脚本
Loading configuration file /opt/flex/frameworks/flex-config.xml
t3.mxml(10): Error: unsupported sampling rate (24000Hz)
[Embed(source="music.mp3")]
t3.mxml(10): Error: Unable to transcode music.mp3.
[Embed(source="music.mp3")]
Run Code Online (Sandbox Code Playgroud)
代码是
<?xml version="1.0"?>
<!-- embed/EmbedSound.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import flash.media.*;
[Embed(source="sample.mp3")]
[Bindable]
public var sndCls:Class;
public var snd:Sound = new sndCls() as Sound;
public var sndChannel:SoundChannel;
public function playSound():void {
sndChannel=snd.play();
}
public function stopSound():void {
sndChannel.stop();
}
]]>
</mx:Script>
<mx:HBox>
<mx:Button label="play" click="playSound();"/>
<mx:Button label="stop" click="stopSound();"/>
</mx:HBox>
</mx:Application>
Run Code Online (Sandbox Code Playgroud)
来自livingocs:
"Flash可以以11,22或44 kHz的采样率导入8位或16位声音.以11 kHz的倍数格式录制的声音(例如8,32或96 kHz)在导入时会重新采样进入Flash.Flash可以在导出时将声音转换为较低的采样率."
Flex Builder不会为您执行此操作,因此您需要在使用之前手动将"music.mp3"文件下采样到22kHz.
编辑:我找不到合适的文档,但在这里说:
"声音采样率 - 以Hz为单位测量,在首次录制声音文件时固定,Flash .SWF文件仅允许四种速率.
Flash SWF格式的采样率为:
5500赫兹
11025赫兹
22050赫兹
44100赫兹(首选设置)"