Commit dddc63af by 前端

空格播放

1 parent 28c5511c
...@@ -48,6 +48,7 @@ export default { ...@@ -48,6 +48,7 @@ export default {
this.$refs.video.addEventListener('pause', () => { this.$refs.video.addEventListener('pause', () => {
this.status = 'play' this.status = 'play'
}) })
document.addEventListener('keydown', this.handleDown)
document.addEventListener('fullscreenchange', function (e) { document.addEventListener('fullscreenchange', function (e) {
let isFull let isFull
if (document.fullscreenElement) { if (document.fullscreenElement) {
...@@ -58,6 +59,16 @@ export default { ...@@ -58,6 +59,16 @@ export default {
this.isFull = true this.isFull = true
}) })
}, },
handleDown(e) {
if (e.keyCode === 32) {
// 执行相应的操作
if (this.status == 'play') {
this.$refs.video.play()
} else {
this.$refs.video.pause()
}
}
},
hanldPlay(status) { hanldPlay(status) {
if (status == 'pause') { if (status == 'pause') {
this.$refs.video.play() this.$refs.video.play()
...@@ -65,6 +76,9 @@ export default { ...@@ -65,6 +76,9 @@ export default {
this.$refs.video.pause() this.$refs.video.pause()
} }
} }
},
beforeDestroy() {
document.removeEventListener('keydown', this.handleDown)
} }
} }
</script> </script>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!