小程序双击暂停事件 分别给播放和暂停一种状态 处理两种状态下的不同情况...

本文介绍了一个基于微信小程序实现的视频播放器组件的交互逻辑,包括播放、暂停、全屏等功能,并通过事件监听来实现播放状态的切换。此外,还涉及了如何在不同状态下显示不同的覆盖元素。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<video id="my-video" src="{{currentVideo.file_url}}" @timeupdate="timeupdate" custom-cache="{{false}}" show-center-play-btn="{{false}}" controls @fullscreenchange="fullScreen" @tap.native="testTap"
@play="setPlayStatus"
@pause="setPauseStatus">
<cover-image class="return" src="{{imageUrl}}/image/video/return.png" wx:if="{{fullScreen}}" @tap="quitFullScreen"></cover-image>
<cover-image src="{{teacherInfo.course_img_url}}" wx:if="{{!playing}}"></cover-image>
<cover-view class="cover-text" wx:if="{{!playing}}">
<cover-view class="text">已有{{teacherInfo.course_study}}人学习了该视频</cover-view>
<!--<cover-view class="button" @tap="playVideo">开始学习</cover-view>-->
</cover-view>
<cover-view class="button" @tap="playVideo" wx:if="{{showBtn}}">开始学习</cover-view>
</video>

setPlayStatus() {
this.isPlaying = true
},
setPauseStatus() {
this.isPlaying = false
},
testTap() {
// 这个里面才能拿到相应的值this.isPlaying 做处理
this.currentTime = Date. now()
if (!this.firstTime) {
this.firstTime = this.currentTime
setTimeout(() => {
this.firstTime = null
}, 350)
}
var mul = (this.currentTime - this.firstTime)
console.log(mul)

if (mul !== 0 && mul < 350) {
console.log('进入函数===', this.isPlaying)
this.isPlaying ? this.videoContext.pause() : this.videoContext.play()
}
return false
},
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

flybirding10011

谢谢支持啊999

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值