Question

call other function when flowplayer complete playing

hi all i am using flowplayer in my website. When flowplayer completes playing an audio file, I want another function to be called which redirect me to another page.

this is code:

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

};

in onFinish function path is hard coded in window.location. I want it dynamic. when it is called by index page it should redirect me to first_instruction, when it is called by first_instruction it should redirect me to second_instruction.

Was it helpful?

Solution

First of all, in the JavaScript code you listed in your question, change this part:

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

to this:

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

next_location will be a JavaScript variable.

Next you need to set this variable within your CakePHP code to value you want. You could do this in the View for each action that uses the flowplayer. The simplest way to put a piece JavaScript into a CakePHP page is to just put something like this into the HTML:

<script type="text/javascript">
    var next_location = "the_location_you_want";
</script>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top