gpt4 book ai didi

javascript - 在视频上叠加播放按钮

转载 作者:可可西里 更新时间:2023-11-01 01:57:08 25 4
gpt4 key购买 nike

我目前有一个脚本可以播放和暂停视频 onclick。我想做的是在开始和暂停时在视频上覆盖一个播放按钮,并在视频再次播放时让同一个按钮消失。

如有任何建议,我们将不胜感激。

HTML

<video class="video"><source src="http://e14aaeb709f7cde1ae68-a1d0a134a31b545b257b15f8a8ba5726.r70.cf3.rackcdn.com/projects/31432/1427815464209-bf74131a7528d0ea5ce8c0710f530bb5/1280x720.mp4" type="video/mp4">
</video>

CSS

.video {
width: 50%;
border: 1px solid black;
}

JS

// Plays and pauses video on click

$('.video').click(function(){this.paused?this.play():this.pause();});

最佳答案

如果您想要实际覆盖您可以编辑的内容,也许这会适合您: https://jsfiddle.net/svArtist/9ewogtwL/

$('.video').parent().click(function () {
if($(this).children(".video").get(0).paused){
$(this).children(".video").get(0).play();
$(this).children(".playpause").fadeOut();
}else{
$(this).children(".video").get(0).pause();
$(this).children(".playpause").fadeIn();
}
});
.video {
width: 100%;
border: 1px solid black;
}
.wrapper{
display:table;
width:auto;
position:relative;
width:50%;
}
.playpause {
background-image:url(http://png-4.findicons.com/files/icons/2315/default_icon/256/media_play_pause_resume.png);
background-repeat:no-repeat;
width:50%;
height:50%;
position:absolute;
left:0%;
right:0%;
top:0%;
bottom:0%;
margin:auto;
background-size:contain;
background-position: center;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="wrapper">
<video class="video">
<source src="http://e14aaeb709f7cde1ae68-a1d0a134a31b545b257b15f8a8ba5726.r70.cf3.rackcdn.com/projects/31432/1427815464209-bf74131a7528d0ea5ce8c0710f530bb5/1280x720.mp4" type="video/mp4" />
</video>
<div class="playpause"></div>
</div>

关于javascript - 在视频上叠加播放按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30309584/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com