Answer the question
In order to leave comments, you need to log in
How did YouTube make videos autoplay in iPad and iPhone?
Good afternoon! The subject itself, or how it can be done in the video tag
Answer the question
In order to leave comments, you need to log in
Fake click trick worked on ancient versions of iOS
function fakeClick(fn) {
var $a = $('<a href="#" id="fakeClick"></a>');
$a.bind("click", function(e) {
e.preventDefault();
fn();
});
$("body").append($a);
var evt,
el = $("#fakeClick").get(0);
if (document.createEvent) {
evt = document.createEvent("MouseEvents");
if (evt.initMouseEvent) {
evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
el.dispatchEvent(evt);
}
}
$(el).remove();
}
$(function() {
var video = $("#someVideo").get(0);
fakeClick(function() {
video.play();
});
});
<input type="button" value="Play" onclick="document.myMovie.play()">
Is it autoplay?
In my opinion, one click is required. And in the context of the click handler, you can start playing the video.
I just did video.play(); and it works, but there the call was in the execution context after changing the slide on the screen, maybe this somehow affected the work.
doing like this
<script>
myVid=document.getElementById("video1");
myVid.play();
</script>
Mozilla/5.0 (iPad; U; CPU OS 6_1 like Mac OS X; ja-jp) AppleWebKit/536.26 (KHTML, like Gecko) Version/6 Mobile/10B141 Safari/8536.25
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question