- まっすぐに、最短の解決策は、HTMLページ上にビデオを作成することです。実際には、WordPressの「生のHTML」要素を使用します。
<script type="text/javascript">
var video = null;
var ended = false;
function checkScroll()
{
if(video == null)
return;
var rect = video.getBoundingClientRect();
// console.log(rect.top, rect.bottom, window.innerHeight, document.documentElement.clientHeight);
var inViewPort = Math.abs(rect.top) < window.innerHeight;
if(inViewPort)
{
if(video.paused && (ended == false))
{
video.play();
video.addEventListener('ended', myHandler, false);
function myHandler(e)
{
ended = true;
}
}
}
else
{
video.currentTime = 0;
ended = false;
}
}
window.onload = function()
{
video = document.getElementById('rubi-second-video');
window.onscroll = function()
{
checkScroll();
}
}
checkScroll();