2013-10-15 34 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>