使用浏览器运行@loadedmetadata事件能够正常触发,然而使用真机调试运行时@loadedmetadata不会触发。代码如下:
<video :id="'myVideo' + videoKey" class="video-player" :src="currentVideoSrc" :autoplay="true"
:direction="90" show-fullscreen-btn object-fit="fill" @pause="onPause" @play="onPlay"
@timeupdate="onTimeUpdate" @loadedmetadata="onLoadedMetadata" @ended="onEnded" @error="onVideoError"
@fullscreenchange="onFullscreenChange">
</video>
onLoadedMetadata(e) {
console.log('进入', e)
this.videoDuration = e.detail.duration;
const chapter = this.chapters[this.currentChapterIndex];
// 更新章节的实际时长
if (chapter.duration !== this.videoDuration) {
chapter.duration = this.videoDuration;
// 重新计算lastPosition
this.parseProgressFromString(this.currentChapterIndex);
}
console.log('chapter.lastPosition', chapter.lastPosition)
// 跳转到指定位置
if (!this.hasSeeked && chapter.lastPosition > 0) {
setTimeout(() => {
this.videoContext.seek(chapter.lastPosition);
this.hasSeeked = true;
}, 300);
}
},
1 个回复
爱豆豆 - 办法总比困难多
你说的真机调试是app端吗?