How can flash call jquery function in its event

Posted by user2955639 on Stack Overflow See other posts from Stack Overflow or by user2955639
Published on 2013-11-05T09:50:28Z Indexed on 2013/11/05 9:53 UTC
Read the original article Hit count: 184

Filed under:
|
|
|
|

I want jquery to do something during some of the events when an audio is playing. So I'm coding a function like this

<script>
$.fn.playMedia = function(options){
    var opts = $.extend({},
                        {
                            swfSrc: ''
                            timeUpdated: function(currentTime){},
                            startPlay: function(){},
                            endPlay: function(){}
                        },
                        options);

    return $(this).each(function(){
        // call flash to play the media whose src is opts.swfSrc
        // Is it possible that flash can call the js functions(opts.timeUpdate, opts.startPlay and opts.endPlay) at each time of the event is triggered?
    });
}};
</script>

// Usage
<div id="player"></div>
<script>
    $('#player').playMedia({
        swfSrc: '/path/song.mp3',
        timeUpdated: function(currentTime){
            comsole.log(currentTime);
        }
    });
</script>

I'm a totally layman of flash, I just guess this works. Hope someone could tell me how to make up a swf file for this jquery function. Or is there any existing jquery plugin which does this thing but can re-design apperance flexibly. Thank you very much!

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery