1

我正在使用 greensock LoaderMax 来加载视频文件和声音文件。我复制了尽可能多的代码。正在播放视频(s9),并且在视频中以一定的百分比播放,我需要播放另一个声音。

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();
}

我猜你只是不能在 playProgress 上做一个 if() 吗?此外,我在 AS3 上很烂。

4

2 回答 2

2

您应该能够只听视频上的 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() 并且它不会发生:)

于 2012-04-01T09:16:28.770 回答
1

我以前没有使用过这个类,但是在阅读了文档之后,看起来你可以做这样的事情: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
}
于 2012-03-31T05:17:19.480 回答