Reputation:
This will fire the alert each time the play button is clicked. So it will be fired the first time the video is played but also on subsequent plays and if the user pauses then then plays again:
$('video').bind('play', function() {
alert('I have been played!');
});
I need to fire an event only once when the video is played for the first time. How can this be done?
Perhaps the jquery one function can be combined with this to make it happen?
Upvotes: 5
Views: 3951
Reputation: 31
$(document).ready(function(){
$('#video_id').one('play', function () {
//code here
});
});
Upvotes: 0
Reputation: 191749
$('video').one('play', function () {
//whatever you want to do
});
Upvotes: 14