Actionscript Sound Channel 仅在 Firefox 中播放

发布于 2024-10-11 14:17:43 字数 1728 浏览 5 评论 0原文

我制作了一些混搭混合地图、翻译 api 和 flickr。我从地图上获取方向,并即时制作 mp3 文件以同时播放它们,但它们只能在 Firefox 中播放,而对于其他浏览器,我只能获得带有背景音乐的第一个声道。不明白为什么。非常感谢任何帮助。

    private var _sound:Sound;
private var _sc:SoundChannel;
private var _isPlaying:Boolean;
private var _url:String;
private var myWatcher:ChangeWatcher;
private var isPlaying:Boolean;

private function _generateSpeech():void {

 var txt:String = description.text;
 var url:String = "http://translate.google.com/translate_tts?tl=en&q=" + txt;
 _url = url;
 var req:URLRequest = new URLRequest(url);

 _sound = new Sound();
 _sound.addEventListener(Event.OPEN, _soundOpenHandle, false, 0, true);
 _sound.addEventListener(ProgressEvent.PROGRESS, _soundProgHandle, false, 0, true);
 _sound.addEventListener(Event.COMPLETE, _soundLoadedHandle, false, 0, true);
 _sound.addEventListener(IOErrorEvent.IO_ERROR, _errorHandle, false, 0, true);
 _sound.load(req,null); 
}
private function _soundOpenHandle(e:Event):void {isPlaying = false;}
private function _soundProgHandle(e:ProgressEvent):void {isPlaying = true;}
private function _soundLoadedHandle(e:Event):void {isPlaying = true;}
private function _playbackCompleteHandle(e:Event):void {isPlaying = false;}
private function _errorHandle(e:IOErrorEvent):void {trace(e);}

private function _playSpeech():void {
 _generateSpeech(); 
 _sc = new SoundChannel();
 if (!isPlaying){_sc = _sound.play(0,0,null);}
 _sc.addEventListener(Event.SOUND_COMPLETE, _playbackCompleteHandle, false, 0, true);
}
public function initWatcher():void {
 ChangeWatcher.watch(description, "text", watcherListener); 
}
// Event listener when binding occurs. 
public function watcherListener(event:Event):void {   
 if (!isPlaying){_playSpeech(); }
}

I have made a little mashup mixing maps, translate api and flickr. I get the directions from my map and make mp3 files on the fly to play them at the same time but they only play in firefox and for the rest of the browsers I only get my first sound channel with background music. can't figure out why. Any help is highly appreciated.

    private var _sound:Sound;
private var _sc:SoundChannel;
private var _isPlaying:Boolean;
private var _url:String;
private var myWatcher:ChangeWatcher;
private var isPlaying:Boolean;

private function _generateSpeech():void {

 var txt:String = description.text;
 var url:String = "http://translate.google.com/translate_tts?tl=en&q=" + txt;
 _url = url;
 var req:URLRequest = new URLRequest(url);

 _sound = new Sound();
 _sound.addEventListener(Event.OPEN, _soundOpenHandle, false, 0, true);
 _sound.addEventListener(ProgressEvent.PROGRESS, _soundProgHandle, false, 0, true);
 _sound.addEventListener(Event.COMPLETE, _soundLoadedHandle, false, 0, true);
 _sound.addEventListener(IOErrorEvent.IO_ERROR, _errorHandle, false, 0, true);
 _sound.load(req,null); 
}
private function _soundOpenHandle(e:Event):void {isPlaying = false;}
private function _soundProgHandle(e:ProgressEvent):void {isPlaying = true;}
private function _soundLoadedHandle(e:Event):void {isPlaying = true;}
private function _playbackCompleteHandle(e:Event):void {isPlaying = false;}
private function _errorHandle(e:IOErrorEvent):void {trace(e);}

private function _playSpeech():void {
 _generateSpeech(); 
 _sc = new SoundChannel();
 if (!isPlaying){_sc = _sound.play(0,0,null);}
 _sc.addEventListener(Event.SOUND_COMPLETE, _playbackCompleteHandle, false, 0, true);
}
public function initWatcher():void {
 ChangeWatcher.watch(description, "text", watcherListener); 
}
// Event listener when binding occurs. 
public function watcherListener(event:Event):void {   
 if (!isPlaying){_playSpeech(); }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

标点 2024-10-18 14:17:44
_sc = new SoundChannel();
 if (!isPlaying){_sc = _sound.play(0,0,null);}
 _sc.addEventListener(Event.SOUND_COMPLETE, _playbackCompleteHandle, false, 0, true);

if (!isPlaying){
    _sc = _sound.play(0,0,null);}

    if( _sc ) {
        _sc.addEventListener(Event.SOUND_COMPLETE, _playbackCompleteHandle, false, 0, true);
    }
}
_sc = new SoundChannel();
 if (!isPlaying){_sc = _sound.play(0,0,null);}
 _sc.addEventListener(Event.SOUND_COMPLETE, _playbackCompleteHandle, false, 0, true);

if (!isPlaying){
    _sc = _sound.play(0,0,null);}

    if( _sc ) {
        _sc.addEventListener(Event.SOUND_COMPLETE, _playbackCompleteHandle, false, 0, true);
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文