2010-11-18 213 views
0

我想在我的动作脚本中添加以下脚本,以便在外部视频完成后重定向到第一帧,需要脚本建议!

但是我不确定如何自定义适合我的sction脚本的代码。

这是我想用我的AS添加代码:

ns.onStatus = function(info:Object) 
{ 
if(info.code == 'NetStream.Play.Stop') 
{ 
gotoAndPlay(2); 
} 
} 

下一个是原代码,现在我使用的播放外部视频文件。我需要定制上面应该可用于下面的代码。

function checkTime(flv) 
{ 
    var _loc2 = flv.playheadTime; 
    var _loc3 = Math.floor(_loc2/60); 
    var _loc1 = Math.floor(_loc2 % 60); 
    if (_loc1 < 10) 
    { 

     _loc1 = "0" + _loc1; 
    } // end if 

    current_time.text = _loc3 + ":" + _loc1; 
} // End of the function 
flv.pauseButton = pause_btn; 
flv.playButton = play_btn; 
flv.FLVPlayback.align = center; 
var time_interval = setInterval(checkTime, 500, flv); 

ffwd_btn.onRelease = function() 
{ 
    flv.seek(flv.playheadTime + 2); 
}; 
rewind_btn.onRelease = function() 
{ 
    flv.seek(flv.playheadTime - 5); 
}; 
mute_btn.onRelease = function() 
{ 
    if (videoSound.getVolume() == 0) 
    { 
     videoSound.start(); 
     videoSound.setVolume(volLevel); 
    } 
    else 
    { 
     volLevel = _root.videoSound.getVolume(); 
     videoSound.setVolume(0); 
     videoSound.stop(); 
    } // end else if 
}; 
var videoSound = new Sound(this); 
videoSound.setVolume(100); 
flv.contentPath = flvurl; 
fl.video.FLVPlayback.align = center; 

任何人都可以帮我吗?

回答

1

,因为使用的是AS2,以及complete激发事件是与AS2 FLVPlayback组件不一致,并且您已经轮询setInterval,只是比较视频durationplayheadTimecheckTime()功能,像这样:

function checkTime() 
{ 
    // you other stuff here.... 

    if(flv.metadata && flv.metadata.duration > 0) 
    { 
     var prog:Number = Math.round((flv.playheadTime/flv.metadata.duration)*100); 

     if(prog == 100) 
     { 
      //clean up your interval 
      clearInterval(time_interval); 

      // do 'end of video' stuff 
      gotoAndPlay(2); 
     } 
    } 
} 

请注意,duration嵌套在FLVPlayback实例的metadata属性中。直到足够的flv文件加载完成才可用,但由于您正在轮询时间间隔,所以在需要时它会在那里。

应该得到呀呀想要的东西......

+0

谢谢你“GTHMB”您的快速回复,反正我会尽快尝试,让你知道它是如何工作!再次感谢。 – Paul 2010-11-18 22:40:05

+0

放置上面提到的代码后,它不会播放视频。运气不好:( – Paul 2010-11-19 15:47:51

+0

你只是用我的例子中的逻辑来增加你当前的'checkTime()'函数,对吧?添加进度检查不应该中断播放... – gthmb 2010-11-19 16:12:15