当 flowplayer 完成播放时调用其他函数


call other function when flowplayer complete playing

在flowplayer完成播放时调用其他函数

大家好,我在我的网站上使用 Flowplayer。当flowplayer完成播放音频文件时,我希望调用另一个函数,将我重定向到另一个页面。

这是代码:

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。

首先,在问题中列出的 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>