Trying to fire a function at the end of an embedded YouTube iFrame's end. Just need to know how to find the end - after that I am good.
相关问题
- How to fix IE ClearType + jQuery opacity problem i
- jQuery add and remove delay
- Include empty value fields in jQuery .serialize()
- Disable Browser onUnload on certain links?
- how to get selected text from iframe with javascri
Here is the answer I came up with to use on an IFrame... The jQuery function is one that I wrote for my project - you can switch it out for what you need. To note: your YouTube video has to have "enablejsapi=1" added to the url.
Hard to tell from your question, but it sounds like you want to trigger an event when the youtube video is ending. You can setup an event handler using the sample code below.
Most of that is just template code for setting up a new Youtube Player, but the important part is the
events
, in which you register an event handler to fire foronStateChange
, which will run the methodonPlayerStateChange
.Then from there you could have a function along these lines:
event.data
is going to be the action that just occurred, and according to the API docs, the value0
means that the video has ended. From there you can perform some action, as shown by thedoSomeAction();
method.