views:

196

answers:

1

I've got a web page for the iPhone that uses the HTML5 video tags. On the iPhone, such embedded videos are played in the native player. I wanted to notice when the video had ended and when the user had dismissed the video with the "Done" button. Initially, I tried this:

        var video = $("#someVideo").get(0);          
        video.addEventListener('ended', myFunction);

But that only fired when the video was allowed to finish. After some playing around with other events (suspend, stalled, waiting) I found that the "Done" button triggers a 'pause' event. However, when I add this:

        video.addEventListener('pause', myFunction);

my code is called both from the "Done" button and when the user taps the pause button in the playback controls. The second case is undesirable; I only want the first case, but the events don't seem to be giving me enough information.

Does anyone know of a way to tell when the user has hit the "Done" button in the iPhone player (versus simply pausing)?

A: 

There is an event called "ended" that you should probably use, see http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#event-media-ended .

Silvia
Thanks, but as I mentioned, I initially tried 'ended', but it only triggers when the video is allowed to play to completion. Clicking "Done" is not the same.
jak