From 6b0655be5559a9832d2e4dc0ddec85222aa17b9a Mon Sep 17 00:00:00 2001 From: Ernie Park Date: Thu, 1 Mar 2012 15:43:29 -0500 Subject: [PATCH] prevent autoplay on iOS devices (which doesnt work anyway). fixes videos so user can click play and it'll play --HG-- branch : ernie-static-fix-ios-video --- js/video_player.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/js/video_player.js b/js/video_player.js index 73a727a14c..59f22dd69d 100644 --- a/js/video_player.js +++ b/js/video_player.js @@ -198,7 +198,7 @@ function onYouTubePlayerAPIReady() { } }); updateytplayerInfoInterval = setInterval(updateHTML5ytplayerInfo, 200); - ajax_videoInterval = setInterval(ajax_video, 5000); + //ajax_videoInterval = setInterval(ajax_video, 5000); } // Need this function to call the API ready callback when we switch to a tab with AJAX that has a video @@ -209,9 +209,26 @@ function loadHTML5Video() { } } +function isiOSDevice(){ + var iphone = "iphone"; + var ipod = "ipod"; + var ipad = "ipad"; + var uagent = navigator.userAgent.toLowerCase(); + + //alert(uagent); + if (uagent.search(ipad) > -1 || uagent.search(iphone) > -1 + || uagent.search(ipod) > -1) { + return true; + } + return false; +} + function onPlayerReady(event) { - // alert("ready"); - event.target.playVideo(); + //do not want to autoplay on iOS devices since its not enabled + //and leads to confusing behavior for the user + if (!isiOSDevice()) { + event.target.playVideo(); + } } function onPlayerStateChange(event) {