在某些playProgress或videotime播放声音时用绿色表示声音?
我正在使用Greensock LoaderMax加载视频文件和声音文件。我已经复制了尽可能多的代码。视频(s9)正在播放,并且在视频中以一定比例播放,我需要播放另一个声音。在某些playProgress或videotime播放声音时用绿色表示声音?
if(s9.playProgress > .1) // This is what I can't get to work
{
s12_sound.playSound(); //This sound won't play at .1 playProgress
}
s9.content.visible = true;
s9.playVideo();
stop();
s9.addEventListener(VideoLoader.VIDEO_COMPLETE, play_s9_loop); //This plays a video once s9 is done.
function play_s9_loop(event:Event):void
{
s9.content.visible = false;
s9_loop.content.visible = true;
s9_loop.playVideo();
}
我猜你只是不能做一个if()on playProgress?此外,我吮吸AS3。
你应该能够在视频上监听INIT事件(通常意味着它已经加载足够的时间来确定视频的持续时间),然后添加AS提示点。
//...after you create your VideoLoader...
myVideoLoader.addEventListener(LoaderEvent.INIT, initHandler);
myVideoLoader.load();
function initHandler(event:LoaderEvent):void {
myVideoLoader.addASCuePoint(myVideoLoader.duration * 0.1, "myLabel");
myVideoLoader.addEventListener(VideoLoader.VIDEO_CUE_POINT, cuePointHandler);
}
function cuePointHandler(event:LoaderEvent):void {
trace("Hit the cue point " + event.data.name);
s12_sound.playSound();
}
此外,请确保您预先加载了s12_sound,以便它可以在您需要时播放。否则,你可以调用playSound()所有你想要的,它不会发生:)
我没有使用过这种课前阅读,但它看起来的文档后,一样可以做这样的事情: http://www.greensock.com/as/docs/tween/com/greensock/loading/VideoLoader.html
var mid:Number = s9_loop.duration/2; //get the midpoint using the duration property
s9_loop.addASCuePoint(mid, "middle") //using addASCubePoint to add a cuepoint to the midpoint of the video
s9_loop.addEventListener(VideoLoader.VIDEO_CUE_POINT, handleMidpoint); //listen for the cuepoint
里面的处理函数
protected function handleMidpoint(e:Event):void{
//play your sound
}
没有骰子,没有发挥声音。为了使它更简单,我知道我需要它玩的时间,但我无法得到它的工作,但我怎么会写入一个计时器,在进入框架时执行,然后在59秒后播放声音?我尝试了一个类似的计时器,但我无法正常工作。 – ahainen 2012-03-31 23:38:18
计时器不会给你所需要的准确性,我不会走这条路。你知道VIDEO_CUE_POINT侦听器是否正在触发吗?我会寻找一些使用它的例子 – francis 2012-04-01 00:10:56
试着看看这个:http://actionscriptexamples.com/2008/03/13/dynamically-adding-cue-points-to-an-flv-using-the -flvplayback-control-in-actionscript-30/- 是否在视频加载后添加提示点? – francis 2012-04-01 00:13:46
好的,我试过了,它会记录“击中提示点myLabel”,但它不会播放声音。我确定函数在我的加载队列之后,并且INIT侦听器在之前。我猜我还有一件事是阻止声音播放,但这可能是十亿次事件,项目代码分散在大量帧中。如果我发现问题,我会在这里重新发布。 – ahainen 2012-04-01 16:21:44
WHATTTTTTTT,好的,当我发表这个并把它放在网上时,它出于某种原因并发挥了声音。不知道那是什么,但它现在起作用。非常感谢你的帮助。再次,我在接下来的几天里玩这个游戏,如果我知道我会发布什么问题。 – ahainen 2012-04-01 18:54:45