我正在尝试制作6个视频的滑块(所有视频的宽度相同),以便仅在手机上观看。当我专注于视频时,它必须开始并自动变大。
我的问题是我不知道如何找出显示哪个幻灯片来启动此幻灯片上的视频。
我认为有一些功能可以找到滑块位置,但是没有找到任何人。我考虑过要获得滑块中间的当前坐标,但找不到如何获取
<body>
<div class="example-wrapper">
<div class="container both-scroll both-mandatory align-center">
<div class="wrapper">
<div class="empty"></div>
<div class="element">
<video width="" height="" controls>
<source src="https://storage.coverr.co/videos/coverr-subway-arriving-1567246574152?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6IjExNDMyN0NEOTRCMUFCMTFERTE3IiwiaWF0IjoxNTY4ODg3OTI4fQ.bwTlDESkfV9tTHITf4WqKvEs3MIOlfik0bw3fX3huuo" type="video/mp4">
<source src="https://storage.coverr.co/videos/coverr-subway-arriving-1567246574152?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6IjExNDMyN0NEOTRCMUFCMTFERTE3IiwiaWF0IjoxNTY4ODg3OTI4fQ.bwTlDESkfV9tTHITf4WqKvEs3MIOlfik0bw3fX3huuo" type="video/ogg">
Your browser does not support the video tag.
</video>
</div>
<div class="element">
<video width="" height="" controls>
<source src="https://storage.coverr.co/videos/coverr-subway-arriving-1567246574152?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6IjExNDMyN0NEOTRCMUFCMTFERTE3IiwiaWF0IjoxNTY4ODg3OTI4fQ.bwTlDESkfV9tTHITf4WqKvEs3MIOlfik0bw3fX3huuo" type="video/mp4">
<source src="https://storage.coverr.co/videos/coverr-subway-arriving-1567246574152?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6IjExNDMyN0NEOTRCMUFCMTFERTE3IiwiaWF0IjoxNTY4ODg3OTI4fQ.bwTlDESkfV9tTHITf4WqKvEs3MIOlfik0bw3fX3huuo" type="video/ogg">
Your browser does not support the video tag.
</video>
</div>
<div class="element">
<video width="" height="" controls>
<source src="https://storage.coverr.co/videos/coverr-subway-arriving-1567246574152?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6IjExNDMyN0NEOTRCMUFCMTFERTE3IiwiaWF0IjoxNTY4ODg3OTI4fQ.bwTlDESkfV9tTHITf4WqKvEs3MIOlfik0bw3fX3huuo" type="video/mp4">
<source src="https://storage.coverr.co/videos/coverr-subway-arriving-1567246574152?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6IjExNDMyN0NEOTRCMUFCMTFERTE3IiwiaWF0IjoxNTY4ODg3OTI4fQ.bwTlDESkfV9tTHITf4WqKvEs3MIOlfik0bw3fX3huuo" type="video/ogg">
Your browser does not support the video tag.
</video>
</div>
<div class="element">
<video width="" height="" controls>
<source src="https://storage.coverr.co/videos/coverr-subway-arriving-1567246574152?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6IjExNDMyN0NEOTRCMUFCMTFERTE3IiwiaWF0IjoxNTY4ODg3OTI4fQ.bwTlDESkfV9tTHITf4WqKvEs3MIOlfik0bw3fX3huuo" type="video/mp4">
<source src="https://storage.coverr.co/videos/coverr-subway-arriving-1567246574152?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6IjExNDMyN0NEOTRCMUFCMTFERTE3IiwiaWF0IjoxNTY4ODg3OTI4fQ.bwTlDESkfV9tTHITf4WqKvEs3MIOlfik0bw3fX3huuo" type="video/ogg">
Your browser does not support the video tag.
</video>
</div>
<div class="element">
<video width="" height="" controls>
<source src="https://storage.coverr.co/videos/coverr-subway-arriving-1567246574152?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6IjExNDMyN0NEOTRCMUFCMTFERTE3IiwiaWF0IjoxNTY4ODg3OTI4fQ.bwTlDESkfV9tTHITf4WqKvEs3MIOlfik0bw3fX3huuo" type="video/mp4">
<source src="https://storage.coverr.co/videos/coverr-subway-arriving-1567246574152?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6IjExNDMyN0NEOTRCMUFCMTFERTE3IiwiaWF0IjoxNTY4ODg3OTI4fQ.bwTlDESkfV9tTHITf4WqKvEs3MIOlfik0bw3fX3huuo" type="video/ogg">
Your browser does not support the video tag.
</video>
</div>
<div class="element">
<video width="" height="" controls>
<source src="https://storage.coverr.co/videos/coverr-subway-arriving-1567246574152?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6IjExNDMyN0NEOTRCMUFCMTFERTE3IiwiaWF0IjoxNTY4ODg3OTI4fQ.bwTlDESkfV9tTHITf4WqKvEs3MIOlfik0bw3fX3huuo" type="video/mp4">
<source src="https://storage.coverr.co/videos/coverr-subway-arriving-1567246574152?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6IjExNDMyN0NEOTRCMUFCMTFERTE3IiwiaWF0IjoxNTY4ODg3OTI4fQ.bwTlDESkfV9tTHITf4WqKvEs3MIOlfik0bw3fX3huuo" type="video/ogg">
Your browser does not support the video tag.
</video>
</div>
<div class="empty"></div>
</div>
</div>
</div>
</body>
<style>
body {
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
}
video{
width: 50vw;
}
.align-center .element {
scroll-snap-align: center;
}
.example-wrapper {
text-align: center;
width: 350vw;
margin-left: auto;
margin-right: auto;
}
.container {
width: 100%;
height: 60vh;
margin-left: auto;
margin-right: auto;
overflow: auto;
position: relative;
-webkit-overflow-scrolling: touch;
scroll-snap-type: mandatory;
}
.element {
height: 60vh;
scroll-snap-stop: normal;
display: flex;
justify-content: center;
align-items: center;
position: relative;
}
.both-mandatory {
scroll-snap-type: both mandatory;
}
.both-scroll .wrapper {
width: 50vw;
height: 100%;
display: grid;
grid-template-columns: 25vw 50vw 50vw 50vw 50vw 50vw 50vw 25vw;
grid-gap: 10px;
}
</style>
我希望确定哪个视频显示在屏幕中央,以将其添加到课程中(有效)。
感谢您的帮助
答案 0 :(得分:0)
您可以收听play
标签的video
事件([更多信息])1
$("video").on("play", function(){
$(this).addClass("active");
}
以防万一在视频播放结束时删除活动内容:
$("video").on("ended", function(){
$(this).removeClass("active");
}