2***@qq.com
2***@qq.com
  • 发布:2025-09-11 16:15
  • 更新:2025-09-11 17:27
  • 阅读:24

真机调试下video的@loadedmetadata事件不触发

分类:uni-app

使用浏览器运行@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);  
                }  
            },
2025-09-11 16:15 负责人:无 分享
已邀请:
爱豆豆

爱豆豆 - 办法总比困难多

你说的真机调试是app端吗?

要回复问题请先登录注册