Events for YouTube embed on Mobile Safari, iPhone (callback on stop)

I'm working on this mobile site, where I need to play a YouTube video in Fullscreen. So far, so good. Just a YouTube embed, and voilá.

But! (Yeah, there's always a «but»)

I need to fire an event (namely, a JS function) when the video ends. I figured Safari translated the YT embed to a <video> tag, so I tried using HTML5s video events, but didn't work:

$('video').bind('ended', function () {
    alert('Video has ended');

This fine piece of code works when using a <video> tag directly, but not when using a YT embed.

So, any ideas on how can I fire this function when the YT video has finished playing?



When you create your YT instance, you can provide a hash that maps events to handlers. Provide a handler for the onStateChange event, and test for the eventType that corresponds to video end ( 0 ).

new YT.Player('player', {
    events: {
        'onStateChange' : function ( eventType ) { if ( == 0 ) { ... } }
} );

See the section of YouTube's JavaScript API for events

Need Your Help

downloading a file from a web directory

php security http authentication .htaccess

i have a form which allows the user to upload some files to a folder.

Non-standard windows with Qt

windows qt user-interface

Is it possible to create a non-standard window with Qt? I mean that I want to create an application with rounded-corner windows and buttons with aqua-like effects. The principal thing is that the app