我如何在Flex中缓存声音资源,我通过以下方式加载声音:
private function set_streamingMedia(mediaURL:String) : void {
var req:URLRequest = new URLRequest(mediaURL);
if (streamChannel) {
streamChannel.stop()
}
auth_play(req);
}
private function auth_play(reqestURL:URLRequest) : void {
stream = new Sound();
var credsHeader:URLRequestHeader = new URLRequestHeader("Authorization", "Basic " + credentials);
reqestURL.requestHeaders.push(credsHeader);
var context:SoundLoaderContext = new SoundLoaderContext(1000, true);
stream.load(reqestURL, context);
timer = new Timer(100);
timer.addEventListener(TimerEvent.TIMER, mediaPositionChange);
play();
}
private function play():void{
if(isPaused){
streamChannel = stream.play(trackPosition);
timer.start();
isPaused = false;
}
else{
if (streamChannel) {
stop();
}
streamChannel = stream.play();
timer.start();
isPaused = false;
}
ChangeVolume();
}
我在剧本上,所以我可以把它保存在一个目录中,把它作为一个BLOB放在SQLite上(看起来像一个可怕的想法) - 想法会非常感激。
还要感谢所有花时间教我Flex的人们:) - 你们比我花钱的书更好!