<template>
<view>
<video
id="videoPlayer"
src="https://goeasy-im.oss-accelerate.aliyuncs.com/goeasy-im-wenwen/uni-video_58379_202105261129.mp4"
@fullscreenchange="onVideoFullScreenChange"
@play="onVideoPlayStart"
></video>
</view>
</template>
export default {
data() {
return {
video: {
context: null,
}
}
},
onReady() {
this.video.context = uni.createVideoContext('videoPlayer');
},
methods: {
onVideoPlayStart() {
this.video.context.requestFullScreen({
direction: 0,
});
},
onVideoFullScreenChange(e) {
if (!e.detail.fullScreen) {
this.video.context.stop();
}
},
}
}