视频未在Safari浏览器中显示,但仅在滚动一点后才会显示 [英] Video not showing in safari, but only does show after a bit of scrolling
本文介绍了视频未在Safari浏览器中显示,但仅在滚动一点后才会显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个视频,在使用Safari时,没有响应它的方式。它负载,因为我可以听到视频的声音,但我只能看到我滚动了一下后的视频。换句话说:视频不可见,直到我滚动浏览器窗口。 请点击此处 ,然后点击一个红色的袋子。
I have a video that, while using Safari, is not responding the way it should. It does load because I can hear the sound of the video, but I can only see the video after I've scrolled a bit. In other words: the video is not visible till i scroll the browser window. Please Check here and click on a red bag.
这是我使用的代码:
$('#video-togglebutton').on('click', function() {
var videoDiv = $('#videoDiv').toggle();
if (videoDiv.is(':visible')) {
$('#video').get(0).load();
$('#video').get(0).play();
} else {
$('#video').get(0).pause();
}
});
$(document).ready(function() {
$('#video').on('ended', function() {
$('#video').get(0).pause();
$('#videoDiv').toggle();
});
});
#videoDiv {
display:none;
left: 50%;
transform: translate(-50%, 0);
height: 35vw;
position: relative;
text-align:center;
}
#videoBlock{
width:60vw;
height: 35vw;
position: absolute;
top: 0;
left: 0;
left: 50%;
transform: translate(-50%, 0);
}
.videoClick {
text-align: center;
}
.videoClick a {
color: white;
font-size: 1.7em;
cursor: pointer;
cursor: hand
}
video {
background-image: url("{{ 'fotel-photography-loading-3.svg' | url_asset }}");
background-repeat: no-repeat;
background-size: 100px 100px;
background-position: center;
margin-top:-34px;
width:100%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button id="video-togglebutton">Toggle video</button>
<div id="videoDiv" style="display:none">
<div id="videoBlock">
<video preload="preload" id="video">
<source src="https://static.webshopapp.com/shops/054833/files/093143183/fotel-photography-course-tour-workshop-video-4.mp4" type="video/mp4">
</video>
</div>
</div>
if(video.readyState == 4){
$(window).scrollTop($(window).scrollTop()+1);
$(window).scrollTop($(window).scrollTop()-1);
}
推荐答案
hack):
/*makes window scroll down and up again one pixel, after page is loaded*/
$(window).load(function(){
$(window).scrollTop($(window).scrollTop()+1);
$(window).scrollTop($(window).scrollTop()-1);
}
这篇关于视频未在Safari浏览器中显示,但仅在滚动一点后才会显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文