[HTML 5 Video] Play event firing twice
Hello everybody,
I'm trying to write a jQuery plugin for HTML 5 Video (with fallbacks) and I'm facing a strange problem.
The Video Element ( as an HTMLNode) has a method called "play", which I tried to implement in my plugin.
The problem is that when I use my plugin's play method, the event is fired twice and this is because ( I think ) the HTML Video Element already has a method called "played".
Here's a basic version of the code I used :
- /* Plugin's code */
- jQuery.fn.play = function(fn) {
- return (fn) ? this.bind("play",fn) : this.trigger("play");
- }
- $('video').play(function(){ // Attaching a function to the "play" event
- alert('playing !');
- }
- $("#playButton").click(function(){
- $('video').play(); // Two alert windows will be displayed instead of one
- }
I tried to use "triggerHandler" instead of "trigger" but it's not working either, the event isn't fired at all.
If anyone can help...
Thanks !