我找到了自动滚动文字和图片的代码,并将其修改为适用于视频内容(请参阅代码段)。
唯一的问题是自动播放后没有采取行动:
appendChild.
我已尝试过(除其他事项外):
document.getElementById('video').play();
以下是当前形式的代码。任何提示都感激不尽!
(function(){
var top=0;
var par = document.getElementById('par')
var scroll = function() {
top++;
if( top>=par.firstElementChild.offsetHeight )
{
//first element is out of sight, so move to the end of the list
top=0;
par.firstElementChild.style.marginTop='';//reset to -
par.appendChild(par.firstElementChild);
}
else
{
par.firstElementChild.style.marginTop='-'+top+'px';
document.getElementById('video').play();
}
setTimeout(scroll, 10)
}
scroll();
})()
<div id="par">
<div class="container">
<video id="video" width="320" height="240" mute loop autoplay>
<source src="http://benh.am/new_2/img/finger_scroll.mp4" type="video/mp4">
</video>
<video id="video" width="320" height="240" mute loop autoplay>
<source src="http://benh.am/new_2/img/finger_scroll.mp4" type="video/mp4">
</video>
</div>
<div class="container">
<video id="video" width="320" height="240" mute loop autoplay>
<source src="http://benh.am/new_2/img/finger_scroll.mp4" type="video/mp4">
</video>
</div>
<div class="container">
<video id="video" width="320" height="240" mute loop autoplay>
<source src="http://benh.am/new_2/img/finger_scroll.mp4" type="video/mp4">
</video>
</div>
</div>