2013-10-15 27 views
0

流水游戏完成播放时调用其他函数当流水游戏完成播放时调用其他函数

嗨,我在我的网站中使用流水游戏。当流水游戏完成播放音频文件时,我想要调用另一个函数,将其重定向到另一个页面。

这是代码:

load_player = function() { 
flowplayer("player", 
    { 
     src:HOST + "app/webroot/flow_player/flowplayer-3.2.7.swf", 
     wmode:'opaque' 
    }, 
    { 
     // define an advertisement using content plugin 
     plugins:{ 
      content:{ 
       url:HOST + 'app/webroot/flow_player/flowplayer.content.swf', 
       // plugin is initially hidden 
       display:'none', 
       // no background and decorations 
       backgroundGradient:'none', backgroundColor:'transparent', border:0, 
       // position and dimensions 
       bottom:0, right:0, width:0, height:0 

      } 
     }, 
     onFinish:function() { 
     window.location = "first_instruction"; 
     } 
    }); 

};

onFinish函数路径在window.location中被硬编码。我希望它动态。当它被索引页调用时,它应该将我重定向到first_instruction,当它被first_instruction调用时,它应该将我重定向到second_instruction。

+0

'first_instruction'听起来不像一个有效的网址...或者是一个占位符你的榜样? –

回答

0

首先,你在你的问题中列出的JavaScript代码,更改这一部分:

 onFinish:function() { 
      window.location = "first_instruction"; 
     } 

这样:

 onFinish:function() { 
      window.location = next_location; 
     } 

next_location将是一个JavaScript变量。

接下来,您需要在您的CakePHP代码中设置此变量以达到您想要的值。您可以在视图中为使用流式播放器的每个操作执行此操作。 把一块JavaScript插入到页面CakePHP的最简单的方法是只把这样的事情到HTML:

<script type="text/javascript"> 
    var next_location = "the_location_you_want"; 
</script>