On iPhone Safari, when playing HTML5 video, how can I prevent the previous / next buttons from working? The YouTube mobile site does this for advertising, so it is definitely possible.
From my research, I found that pressing the button "next" raises events timeupdate, pause, seekingand ended, roughly in that order. Calling preventDefault()or stopPropagation()in the listener on any of them seems to do nothing (I'm not sure if this is the correct behavior on the iPhone, the Apple Safari dev guide does not provide much information about video events).
So how can I do this? I tried to listen to the event seeking, but it does not seem to fire on the next press (I don't know why). Also, even if I listen to this event, the event endedstill fires right after, and I have not found a way to prevent this. endedIt looks like an event that tells the player to close is NOT what I want.
The ideal IMO method would be to listen timeupdatefor a big change, and then set the currentTimeprop video to its previous value - this is incredibly reliable and works great. If the user clicks the "Next" button, it timeupdatereally works right away; however, it endedalso works, as a result of which the video player closes, making my update currentTimeuseless.
I know this is possible, but there is surprisingly little information on the Internet or SO. Does anyone know how to do this?
source
share