gpt4 book ai didi

actionscript-3 - AS3 播放音频之间不必要的延迟

转载 作者:行者123 更新时间:2023-12-03 02:28:42 25 4
gpt4 key购买 nike

我有一首歌被分成四段:前奏、A、B、结尾。我有一个播放前奏的程序,然后是 A 两次,然后 B 两次,然后再回到 A 并不断重复 AABB,直到我按下结束按钮。如果按下结尾按钮,则结束当前播放的歌曲片段,播放结尾并停止。它就像一个魅力,除了在歌曲之间的过渡中有一个非常明显的、令人讨厌的延迟。我怎样才能摆脱延迟,让它在前一段结束后立即播放歌曲? (我在flash cs6中使用actionscript 3.0,歌曲为mp3格式,导入库中)。
这是程序:
https://dl.dropboxusercontent.com/s/6f9w906x9uja683/Loop%20music%20test.swf
这是我正在使用的代码:

import flash.events.MouseEvent;

stop();
//variables
var track_var: Number = 0;
var music_cnl:SoundChannel = new SoundChannel();
var intro_msc:Sound = new intro_mp3();
var a_msc:Sound = new A_mp3();
var b_msc:Sound = new B_mp3();
var outro_msc:Sound = new ending_mp3();
//stopping the movieclips
a_mc.stop();
b_mc.stop();
ending_btn.stop();

//intro
music_cnl = intro_msc.play();
track_var= 1;
intro_mc.gotoAndStop(2);
music_cnl.addEventListener(Event.SOUND_COMPLETE, playnext_fn);
trace("debug:track value set to",track_var);

//track selector
function playnext_fn(event:Event){
trace("debug:playnext_fn called");
switch(track_var){
case 0:
//stop
music_cnl.stop();
intro_mc.gotoAndStop(1);
a_mc.gotoAndStop(1);
b_mc.gotoAndStop(1);
ending_btn.gotoAndStop(1);
trace("debug:track value set to",track_var);
ending_btn.removeEventListener(MouseEvent.MOUSE_UP, ending_fn);
break;
case 1:
//first A track
track_var=2;
intro_mc.gotoAndStop(1);
b_mc.gotoAndStop(1);
a_mc.gotoAndStop(2);
music_cnl= a_msc.play();
music_cnl.addEventListener(Event.SOUND_COMPLETE, playnext_fn)
trace("debug:track value set to",track_var);
break;
case 2:
//second A track
track_var=3;
music_cnl= a_msc.play();
music_cnl.addEventListener(Event.SOUND_COMPLETE, playnext_fn);
trace("debug:track value set to",track_var);
break;
case 3:
//first B track
track_var = 4
a_mc.gotoAndStop(1);
b_mc.gotoAndStop(2);
music_cnl= b_msc.play();
music_cnl.addEventListener(Event.SOUND_COMPLETE, playnext_fn);
trace("debug:track value set to",track_var);
break;
case 4:
//second B track
track_var=1;
music_cnl= b_msc.play();
music_cnl.addEventListener(Event.SOUND_COMPLETE, playnext_fn);
trace("debug:track value set to",track_var);
break;
case 5:
//ending
a_mc.gotoAndStop(1);
b_mc.gotoAndStop(1);
intro_mc.gotoAndStop(1);
ending_btn.gotoAndStop(2);
music_cnl=outro_msc.play();
track_var=0;
music_cnl.addEventListener(Event.SOUND_COMPLETE, playnext_fn);
trace("debug:track value set to",track_var);
break;

}
}

//ending button
ending_btn.addEventListener(MouseEvent.MOUSE_UP, ending_fn);
function ending_fn(Event:MouseEvent){
track_var=5;
ending_btn.gotoAndStop(2)
trace("debug: ending button pressed|","track value set to",track_var);
}

最佳答案

我没有看到您的代码有问题(除了关于
MAX_BUFFERSIZE,但我认为这看起来像是试图解决问题的残余!)

我认为更可能导致问题的是您的源音频 - 如果它作为 MP3 导入,或 with a bitrate of 48这可能会导致同步问题。

关于actionscript-3 - AS3 播放音频之间不必要的延迟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25127376/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com