Search code examples
javascriptjqueryhtmljquery-pluginsjplayer

jPlayer - confirm box after sound end


How can I show a confirm box after sound end? I use jPlayer HTML5 Audio player to play sound. I have something like:

$(document).ready(function() {
                $("#jquery_jplayer_1").jPlayer({
                    ready: function(event) {
                        $(this).jPlayer("setMedia", {
                            mp3: "http://mysite.com/sound.mp3"
                        });
                    },
                    swfPath: "http://www.jplayer.org/2.1.0/js",
                    supplied: "mp3"
                });             
            });

Solution

  • use ended event:

    $(document).ready(function() {
        $("#jquery_jplayer_1").jPlayer({
            ready: function(event) {
                $(this).jPlayer("setMedia", {
                    mp3: "http://mysite.com/sound.mp3"
                });
            },
            swfPath: "http://www.jplayer.org/2.1.0/js",
            supplied: "mp3",
            ended: function() {
                confirm('The sound ended?');
            }
        });             
    });