视频循环自动播放在Chrome/Safari上不起作用(Webkit错误) [英] Video loop autoplay won't work on Chrome/safari (webkit bug)

查看:435
本文介绍了视频循环自动播放在Chrome/Safari上不起作用(Webkit错误)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我正在尝试自动播放视频并在滑块中循环播放,但有些方法无法在chrome和safari上播放.我发现Webkit浏览器存在一个错误,当重新设置视频自动播放功能时,该错误会停止视频自动播放功能...

Hi guys I am trying to have my video autoplay and loop in a slider but some how it's not playing on chrome and safari. I find out webkit browsers have a bug that stops the video autoplay function when it's restyled...

这是视频和页面. (适用于Firefox) http://dustintong.com/projects.html#ts

Here's the video and the page. (works on firefox) http://dustintong.com/projects.html#ts

我认为您必须重新触发.play() 不知道我做错了什么. javascript新手... 这是下面的代码.

I think you have to re-trigger the .play() Not sure what I did wrong. New to javascript... Here's the code below.

JS

var myVideo = document.querySelector('video');
var mediaController = myVideo.controller;

mediaController.play();

HTML

<div id="video">
<video src="images/7-4s.mp4" autoplay loop muted> 
</video> </div>

推荐答案

在safari中,自动播放就可以了. 如果您将此<video src="images/7-4s.mp4" autoplay loop muted>放入,则不需要任何js. 您可以尝试 https://github.com/videojs/video.js

In safari, autoplay works just fine. If you put this <video src="images/7-4s.mp4" autoplay loop muted> you don't need any js. You can try this plugin https://github.com/videojs/video.js

这篇关于视频循环自动播放在Chrome/Safari上不起作用(Webkit错误)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆