Sonoport如何播放音频(动作) [英] Sonoport how to play audio (actionscript)
问题描述
有手动 http://sonoport.com/manual/ 如何使用AS3库来播放音频音频过滤器。我需要的工具AudioStretch但首先尝试简单的播放音频的外部链接。
There is manual http://sonoport.com/manual/ how to use as3 library to play audio with audio filters. I need tool AudioStretch but firstly try simple to play an audio external link.
我做什么。
- 在我使用mxmlc编译,所以包括SonoportCollection.swc
- 导入com.sonoport.MP3PlayerSound;
- 尝试创建和播放
code:
mp3PlayerSnd = new MP3PlayerSound();
mp3PlayerSnd.audioFile = "http_url_link.mp3";
mp3PlayerSnd.play();
所以,没有什么发挥。我看到HTTP GET到服务器的链接http_url_link.mp3发送确定。但是,没有任何声音。我做错了什么?
So, nothing play. I see that http get to server for link http_url_link.mp3 is sent ok. But there is no sound. What I do wrong?
更新。我尝试测试
package {
import flash.display.Sprite;
import flash.events.*;
import flash.net.URLRequest;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundTransform;
import com.sonoport.MP3PlayerSound;
public class Pitcher extends Sprite {
protected var trackSound:Sound;
protected var trackChannel:SoundChannel;
protected var _mp3_path:String;
public function Pitcher():void {
_mp3_path = 'http_path_to_audio_mp3';
trackSound = new Sound();
trackSound.load(new URLRequest(_mp3_path));
trackChannel = trackSound.play();
}
}
}
这做工精细!当我在浏览器中打开.swf文件正在播放的音乐
This work fine! When I open .swf file in browser the music is playing
package {
import flash.display.Sprite;
import flash.events.*;
import flash.net.URLRequest;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundTransform;
import com.sonoport.MP3PlayerSound;
public class Pitcher extends Sprite {
protected var trackSound:Sound;
protected var trackChannel:SoundChannel;
protected var _mp3_path:String;
public function Pitcher():void {
var snd:MP3PlayerSound;
snd = new MP3PlayerSound();
snd.gain = 1;
snd.audioFile = 'http_path_to_audio_mp3';
snd.play();
}
}
}
这是行不通的。当我在浏览器中打开.swf文件我看到HTTP请求到服务器的MP3文件,这样做,但没有音乐......
This is not working. When I opened in browser .swf file I see that http request to the server for mp3 file is done but there is no music ...
我编译AS3 code与UTIL mxmlc的。一些像这样的命令
I compile AS3 code with util mxmlc. Some like this command
"cd #{as3_path}; #{mxmlc} -include-libraries=SonoportCollection.swc -warnings=false -debug=false -static-link-runtime-shared-libraries=true -optimize=true -o #{swf_file} -file-specs #{as3_file}"
在我的编译器指令可能的问题? PS。我不是Flash开发人员
Maybe problem in my compiler command? ps. I'm not flash developer
推荐答案
感谢迪马, 可我只是确认你:
thanks Dima, can I just confirm that you're:
- 包括*名为.swc
- 导入类
下面的作品对我来说,code作为纯粹的AS3 / Flash的IDE项目,随意上传源链接但如果它不能正常工作。
the code below works for me as a pure AS3 / Flash IDE project, feel free to upload a source link though if it doesn't work.
import com.sonoport.MP3PlayerSound;
var snd:MP3PlayerSound;
snd = new MP3PlayerSound();
snd.gain = 1;
snd.audioFile = "sound.mp3";
snd.play();
我相信增益默认为1,但我通常设置也无妨。
I believe the gain is defaults to 1, but I usually set it anyway.
这篇关于Sonoport如何播放音频(动作)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!