Commit 492c6043 authored by lilei's avatar lilei

视频播放监听

parent 97e31c7a
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div class="video-control"> <div class="video-control">
<div class="video-play-btn" @click="play()">播放</div> <div class="video-play-btn" @click="play()">播放</div>
<div class="video-time-content"> <div class="video-time-content">
<div class="now-time">{{ duration | formatTime }}</div> <div class="now-time">{{ nowTime | formatTime }}</div>
<span>/</span> <span>/</span>
<div class="total-time">{{ duration | formatTime }}</div> <div class="total-time">{{ duration | formatTime }}</div>
</div> </div>
......
...@@ -28,6 +28,9 @@ export default { ...@@ -28,6 +28,9 @@ export default {
this.$refs.videoDom.addEventListener('ended', () => { this.$refs.videoDom.addEventListener('ended', () => {
this.$emit('ended') this.$emit('ended')
}) })
this.$refs.videoDom.addEventListener('timeupdate', () => {
this.$emit('timeupdate', this.$refs.videoDom.currentTime)
})
}) })
}, },
methods: { methods: {
...@@ -39,7 +42,6 @@ export default { ...@@ -39,7 +42,6 @@ export default {
play() { play() {
if (!this.canPlay) return if (!this.canPlay) return
this.$refs.videoDom.play() this.$refs.videoDom.play()
this.$emit('currentTime', this.$refs.videoDom.currentTime)
}, },
pause() { pause() {
if (!this.canPlay) return if (!this.canPlay) return
......
<template> <template>
<div class="video-cutter"> <div class="video-cutter">
<div class="video-content"> <div class="video-content">
<VideoPlayer @currentTime="changeTime" @end="playEnd" /> <VideoPlayer @currentTime="changeTime" @end="playEnd" @timeupdate="timeupdate" />
</div> </div>
<div class="video-btn"> <div class="video-btn">
<videoChange @changeVideo="changeVideo" /> <videoChange @changeVideo="changeVideo" />
...@@ -14,15 +14,11 @@ ...@@ -14,15 +14,11 @@
</template> </template>
<script> <script>
import VideoPlayer from '@/components/videoCutter/videoPlayer.vue'
import VideoChange from '@/components/videoCutter/videoChange.vue'
import VideoControl from '@/components/videoCutter/videoControl.vue'
export default { export default {
components: { components: {
VideoPlayer, VideoPlayer: () => import('@/components/videoCutter/videoPlayer.vue'),
VideoChange, VideoChange: () => import('@/components/videoCutter/videoChange.vue'),
VideoControl VideoControl: () => import('@/components/videoCutter/videoControl.vue')
}, },
name: 'videoCutter', name: 'videoCutter',
data() { data() {
...@@ -66,6 +62,9 @@ export default { ...@@ -66,6 +62,9 @@ export default {
playEnd() { playEnd() {
this.playing = false this.playing = false
this.nowTime = this.duration this.nowTime = this.duration
},
timeupdate(time) {
this.nowTime = time
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment