I'm trying to attach an event listener to my video element. I'd like to start the video if the variable played is less than 1. And then open the link the next time you tap on the video if it's already playing (played > 0). But when I test this on my iPad it's opening the link and playing the video together.
Here's my code...
var played = 0;
var video = document.getElementById('video');
video.addEventListener("touchstart", openLink, false);
function openLink() {
if (played == 0) {
video.play();
played++;
} else if (played != 0){
open("internal-http://example.com", "_blank");
}
}
Can someone point me in the right direction? I've tried "click" and "touchstart" as my events but somehow the browser (UIWebview) is doing both at the same time.