前端如何判断音视频是否播放完毕
1.音频
<audio id="audio"> <source :src="json.RES_PATH" type="audio/mp3"> </audio> <script> var audio = document.getElementById("audio"); audio.loop = false; audio.addEventListener('ended', function () {
//监听到播放结束后,在此处可调用自己的接口
}, false); </script>
2.视频
<video :poster="json.DOC_IMG" id="video" webkit-playsinline="" playsinline="true" controls class="video-box" style="width: 100%;height: 100%; background: #ddd; "> <source :src="json.RES_URL" type="video/mp4"></source> </video> <script> var video = document.getElementById("video"); video.addEventListener('ended', function () { //监听到播放结束后,在此处可调用自己的接口 }, false); </script>