How to disable auto-play for video when src is from my local pc?
I've tried all the possible solutions but nothing worked for local video bindings. I believe best solution would be to fix using jQuery if you still wants to use iframes.
$(document).ready(function () {
var ownVideos = $("iframe");
$.each(ownVideos, function (i, video) {
var frameContent = $(video).contents().find('body').html();
if (frameContent) {
$(video).contents().find('body').html(frameContent.replace("autoplay", ""));
}
});
});
Note: It'll find all the iframes on document ready and loop through each iframe contents and replace/remove autoplay
attribute. This solution can be use anywhere in your project. If you would like to do for specific element then use the code under $.each
function and replace $(video)
with your iframe element id like $("#myIFrameId")
.