Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Possible Duplicate:
$ not defined using jQuery in Wordpress

I need to trigger a alert box when video ends

THis is the code i got from google

<script>
$("iframe[src^='http://www.youtube.com']").bind("ended", function() {
alert("I'm done!");
 });
</script>

I am just using the oembed function of wordpress to play youtube videos

I dont now why there are not working

share|improve this question

marked as duplicate by Tom J Nowell, brasofilo, toscho Jan 28 '13 at 12:51

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Voted to close as off topic, this is a Youtube player issue, not a WordPress issue. The embed itself is defined by Youtube, as is the API, as is the JS, as is the player controls. This is a Javascript question should belongs on the main Stack Overflow site –  Tom J Nowell Jan 28 '13 at 10:56
    
i added here becuase the script works in normall php sites but doesnt works in wordpress as wordpress is using o-embed function to embed videos –  vaibhav Jan 28 '13 at 11:15
    
So it is not a WordPress issue it's an OEmbed issue? Then it's still offtopic –  Tom J Nowell Jan 28 '13 at 11:54

1 Answer 1

You can track the state of the youtube video, do you have the link to the youtube video? Use this youtube API function to get the result, and if it hits you back with a "0" you can initiate the alert(); function

player.getPlayerState():Number

Returns the state of the player. Possible values are unstarted (-1), ended (0), playing (1), paused (2), buffering (3), video cued (5).

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.