我正在包裝一個Squarespace網站,唯一的問題是我試圖向頭添加MP4,我能夠找到一些代碼,但問題是視頻不斷循環,即使我加了loop =「false」......有沒有辦法結束循環,一旦結束,通過css「顯示:無」?在SquareSpace結束後隱藏視頻
https://marina-toybina.squarespace.com
<script type="text/javascript">
$(window).bind("load", function() {
if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
} else {
var banner = $('#pageWrapper img').first();
if (banner.length === 0)
banner = $('.banner-thumbnail-wrapper > #thumbnail > img').first();
if (banner.length === 0)
banner = $('#parallax-images img').first();
if (banner.length === 0)
banner = $('.has-main-image img').first();
if (banner.length === 0)
banner = $('#page-thumb img').first();
var url = "/s/Countdown-Intro_06.mp4";
banner.hide();
$('<video class="bannerVideo" autoplay="" loop="false" preload><source src="' + url + '" type="video/mp4"></video>').insertAfter(banner);
adjustBanner($('.bannerVideo'), banner);
setTimeout(function() {
adjustBanner($('.bannerVideo'), banner);
}, 2000);
$(window, banner).resize(function() {
adjustBanner($('.bannerVideo'), banner);
setTimeout(function() {
adjustBanner($('.bannerVideo'), banner);
}, 200);
});
}
function adjustBanner (video, banner) {
video.css({
height: banner.css('height'),
width: banner.css('width'),
top: banner.css('top'),
left: banner.css('left'),
position: 'relative',
'object-fit': 'inherit'
});
}
});
</script>
這是YouTube視頻嗎?因爲如果是這樣,那麼你可以使用YouTube的API來創建一個視頻,然後跟蹤它完成 - http://stackoverflow.com/questions/25184549/hide-div-after-youtube-video-ends – Adjit
其實它是一個MP4 ... :( –
那麼在這種情況下,仍然非常簡單和可以:http://stackoverflow.com/questions/2741493/detect-when-an-html5-video-finishes – Adjit