为什么我的 mp4 视频不能在手机上播放? [英] Why my mp4 video does not play on mobile?
问题描述
我正在尝试让 mp4 视频自动播放以在我的移动网站上运行.我在我的两个网站上都应用了相同的技术,但它不仅仅适用于其中一个,这很奇怪!我觉得我的想法快用完了!
I am trying to make mp4 video autoplay to work on my website on mobile. I have applied same technique to do it on both of my websites and it is not working only on one of them which is very strange! I feel like I am running out of ideas!
这是第一个不起作用的网站:https://wearepharos.com/ pw:pharos123它托管在 Shopify 上.
Here is the first website where it does not work: https://wearepharos.com/ pw:pharos123 It is hosted on Shopify.
这是我做同样事情的另一个网站,但不知何故它在移动设备上运行:https://sebastianwalach.com/
Here is another website where I do same thing but somehow it is working on mobile: https://sebastianwalach.com/
我正在使用此脚本将内联播放添加到在第二个网站上完成工作的视频中:
I am using this script to add playsinline to the video which does the job on the second website:
<script>
setTimeout(
function(){
var mobilevideo = document.getElementsByTagName("video");
var i;
for (i = 0; i < mobilevideo.length; i++) {
mobilevideo[i].setAttribute("playsinline", "");
}
},
3000);
</script>
请帮帮我!
推荐答案
我没有找到该问题的正确解释,但我应用了一个实际上运行良好的hack"jQuery 修复程序.我发布它,因为它可能对某人有用:
I didn't find a correct explanation for that issue but instead I applied a "hack" jQuery fix that is actually working just fine. I am posting it as maybe it will be useful for someone:
function playVid() {
$('video').get(0).play();
}
setTimeout(playVid, 3000);
这篇关于为什么我的 mp4 视频不能在手机上播放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!