// backPlayVideo.vue
<template>
<view>
<video
id="myVideo"
class="videoWrap"
autoplay="true"
controls="false"
src="/static/video.mp4">
<cover-image class="fullscreen" v-if="!isFullScreenStatus" src="../../static/fullscreen.png" @click="fullScreenBtn"></cover-image>
<cover-image class="exitfullscreen" v-if="isFullScreenStatus" src="../../static/noFullscreen.png" @click="ExitFullScreenBtn"></cover-image>
</video>
</view>
</template>
<script>
export default {
data() {
return {
contextVideo: null,
isFullScreenStatus: false
}
},
mounted () {
this.contextVideo = uni.createVideoContext('myVideo')
},
methods: {
fullScreenBtn () {
this.isFullScreenStatus = !this.isFullScreenStatus
this.contextVideo.requestFullScreen()
},
ExitFullScreenBtn () {
this.isFullScreenStatus = !this.isFullScreenStatus
this.contextVideo.exitFullScreen()
}
}
}
</script>
<style scoped>
.videoWrap {
width: 750rpx;
}
.fullscreen {
position: absolute;
bottom: 30rpx;
right: 30rpx;
width: 50rpx;
height: 50rpx;
}
.exitfullscreen {
position: absolute;
bottom: 15rpx;
right: 15rpx;
width: 30rpx;
height: 30rpx;
}
</style>
video组件上添加图标(uni-app)
最新推荐文章于 2024-04-25 08:45:16 发布