如果是jquery也是一样
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>BFW NEW PAGE</title>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/jquery-3.2.1.min.js"></script>
</head>
<body>
<spanBfwOnclick="play();">播放/暂停</span>
<spanBfwOnclick="resume();">重新播放</span>
<audio id="sound" src="//repo.bfw.wiki/bfwrepo/sound/5c89fd22dea6948307.mp3"></audio>
<script>
var videoEl = $("#sound")[0];
function play() {
if (videoEl !== null) {
//检测播放是否已暂停.audio.paused 在播放器播放时返回false.
if (videoEl.paused) {
videoEl.play(); //audio.play();// 这个就是播放
} else {
videoEl.pause(); // 这个就是暂停
}
}
}
function resume() {
if (videoEl !== null) {
videoEl.currentTime = 0;
videoEl.play();
}
}
videoEl.addEventListener('play', function () {})
//播放进度监听
videoEl.addEventListener('timeupdate', function () {
var vTime = videoEl.currentTime;
var total_vtime = videoEl.duration;
//4秒后暂停播放
if (vTime >= 4) {
videoEl.currentTime = 0;
videoEl.pause();
}
})
</script>
</body>
</html>
网友回复
ai先写功能代码通过chrome mcp来进行测试功能最后ai美化页面这个流程能行吗?
vue在手机端上下拖拽元素的时候如何禁止父元素及body的滚动导致无法拖拽完成?
使用tailwindcss如何去掉响应式自适应?
有没有直接在浏览器中运行的离线linux系统?
nginx如何保留post或get数据进行url重定向?
python有没有能绕过Cloudflare人机验证的爬虫库?
有没有免费的股票量化交易本地部署预测模型?
如何根据一张人脸照片全网人肉搜索这个人的其他照片或信息?
js版本iife esm umd cjs有啥区别?
如何将ctrl+c复制的网页图文列表自动解析成可编辑的电子表格?