@timeupdate="timeupdate" @fullscreenchange="fullscreenchange"></video>
<button class="btn" @click="play">播放</button>
<button class="btn" @click="pause">暂停</button>
</div>
</template>
<script>
const sysInfo = uni.getSystemInfoSync();
export default {
data: {
src: 'http://cdnoss.banlamwe.com/up/20200713/92c6746514198123d668627b5c8291b9.mp4',
fil: true,
list: [{
text: '要显示的文本',
color: '#FF0000',
time: 9
}],
currentClock: '',
videoDuration: ''
},
onReady() {
this.context = uni.createVideoContext("video1", this);
},
computed: {
processWidth() {
if (this.fullScreen) {
return sysInfo.windowHeight - 69 - (sysInfo.platform == 'ios' ? 0 : sysInfo.statusBarHeight);
} else {
return sysInfo.screenWidth - 69;
}
},
},
methods: {
onstart(e) {
console.log("onstart:" + JSON.stringify(e));
},
onpause(e) {
console.log("onpause:" + JSON.stringify(e));
},
onfinish(e) {
console.log("onfinish:" + JSON.stringify(e));
},
onfail(e) {
console.log("onfail:" + JSON.stringify(e));
},
fullscreenchange(e) {
console.log("fullscreenchange:" + JSON.stringify(e));
},
waiting(e) {
console.log("waiting:" + JSON.stringify(e));
},
timeupdate(e) {
// console.log("timeupdate:" + JSON.stringify(e));
this.currentClock = e.detail.currentTime;
this.videoDuration = e.detail.duration;
var a = this.currentClock/this.videoDuration * this.processWidth;
},
play() {
this.context.play();
},
pause() {
this.context.pause();
},
seek() {
var pos = this.currentClock + 10;
console.log(pos)
this.$refs.mainVideo.seek(pos);
},
stop() {
this.context.stop();
},
fullScreen() {
this.context.requestFullScreen({
direction: 90
});
},
exitFullScreen() {
this.context.exitFullScreen();
},
sendDanmu() {
this.context.sendDanmu({
text: '要显示的弹幕文本',
color: '#FF0000'
});
},
playbackRate() {
this.context.playbackRate(2);
},
handleJump() {
uni.navigateTo({
url: '/pages/API/websocket-global/websocket-global'
})
}
},
onUnload() {
console.log('onunload');
}
}
</script>
<style>
.video {
width: 750rpx;
height: 400rpx;
background-color: #808080;
}
.btn {
margin-top: 5px;
margin-bottom: 5px;
;
}
</style>
0 个回复