【发布时间】:2014-07-27 17:30:43
【问题描述】:
我的网站有一个 HTML5 视频背景。一旦通过它播放然后定向到锚链接。
这很好用,我唯一的问题是一旦我实现了指向锚定链接的功能,视频就会停止自动播放!?
网站基于FullPage.js
这是我的视频功能的代码:
$(document).ready(function() {
$('#fullpage').fullpage({
verticalCentered: true,
sectionsColor: ['#fff', '#fff', '#fff', '#fff', '#fff'],
anchors: ['firstPage', 'secondPage', '3rdPage', '4thpage', 'lastPage'],
menu: '#menu',
afterRender: function(){
//playing the video
$("#myVideo").play().on("ended", function load() {
window.location.hash="secondPage"
});
}
});
});
这是视频中加载的代码。
<video autoplay controls id="myVideo">
<source src="intro.mp4" type="video/mp4">
</video>
我尝试使用 autoplay='autoplay' 和各种变体,但没有成功。 :(
有什么建议吗?
干杯
【问题讨论】:
-
破解了! document.getElementById("myVideo").play(); $("#myVideo").on("end", function load() { window.location.hash="secondPage"跨度>
标签: jquery html function video fullpage.js