zpy
zpy
  • 发布:2021-02-24 11:23
  • 更新:2022-01-22 15:25
  • 阅读:603

【报Bug】uniapp 视频api seek方法 是线上链接 跳转帧无问题 如果是本地视频 跳转帧 就会不准

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: windows10 专业版

HBuilderX类型: 正式

HBuilderX版本号: 3.1.3

手机系统: Android

手机系统版本号: Android 10

手机厂商: 联想

手机机型: 小新pad

页面类型: nvue

打包方式: 云端

项目创建方式: HBuilderX

示例代码:
    <div>  
        <video id='video1' class="video" :src="video.src" autoplay="false" duration="" controls="true" :danmu-list="list"  
         danmu-btn="true" enable-danmu="true" :loop="true" muted="true" initial-time="" direction="-90" show-mute-btn="true"  
         @play="onstart" @pause="onpause" @ended="onfinish" @error="onfail" @waiting="waiting" @timeupdate="timeupdate"  
         @fullscreenchange="fullscreenchange"></video>  
        <button class="btn" @click="seek">跳转到指定位置</button>  
    </div>  
</template>  

<script>  
    export default {  
        data: {  
            src: "https://img.cdn.aliyun.dcloud.net.cn/guide/uniapp/%E7%AC%AC1%E8%AE%B2%EF%BC%88uni-app%E4%BA%A7%E5%93%81%E4%BB%8B%E7%BB%8D%EF%BC%89-%20DCloud%E5%AE%98%E6%96%B9%E8%A7%86%E9%A2%91%E6%95%99%E7%A8%8B@20181126-lite.m4v",  
            fil: true,  
            list: [{  
                text: '要显示的文本',  
                color: '#FF0000',  
                time: 9  
            }],  
            video: {  
                src: ''  
            },  
            videoList: [],  
            videoTxt: ''  
        },  
        onReady() {  
            this.context = uni.createVideoContext("video1", this);  
            this.localFile()  
        },  
        methods: {  
            localFile() {  
                plus.io.requestFileSystem(plus.io.PUBLIC_DOWNLOADS, (fs) => {  
                    var directoryReader = fs.root.createReader();  
                    directoryReader.readEntries((entries) => {  
                        if (entries.length == 0) resolve()  
                        for (let i = 0; i < entries.length; i++) {  
                            //获取路径  
                            entries[i].file((file) => {  
                                this.videoInfo(file)  
                            });  
                        }  
                    })  
                }, function(e) {  
                    console.log("Read entries failed: " + e.message);  
                });  
            },  
            videoInfo(file) {  
                console.log(file)  
                plus.io.getVideoInfo({  
                    filePath: "file://" + file.fullPath,  
                    success: (videoInfo) => {  
                        //本地支持mp4 flv  
                        this.videoList.push({  
                            srcList: "file://" + file.fullPath,  
                            title: file.name,  
                            gDuration: videoInfo.duration, //大概总时长  
                        })  
                        console.log(this.videoList)  
                        this.video.src = this.videoList[0].srcList  
                    },  
                    fail: () => {  

                    },  
                    complete: () => {  

                    }  
                })  
            },  
            onstart(e) {  
                console.log("onstart:" + JSON.stringify(e));  
            },  
            onpause(e) {  
                console.log("onpause:" + JSON.stringify(e));  
            },  
            onfinish(e) {  
                console.log("onfinish:" + JSON.stringify(e));  
            },  
            onfail(e) {  
                console.log("onfail:" + JSON.stringify(e));  
            },  
            fullscreenchange(e) {  
                console.log("fullscreenchange:" + JSON.stringify(e));  
            },  
            waiting(e) {  
                console.log("waiting:" + JSON.stringify(e));  
            },  
            timeupdate(e) {  
                // console.log("timeupdate:" + JSON.stringify(e));  
            },  

            play() {  
                this.context.play();  
            },  
            pause() {  
                this.context.pause();  
            },  
            seek() {  
                this.context.seek(20);  
            },  
            stop() {  
                this.context.stop();  
            },  
            fullScreen() {  
                this.context.requestFullScreen({  
                    direction: 90  
                });  
            },  
            exitFullScreen() {  
                this.context.exitFullScreen();  
            },  
            sendDanmu() {  
                this.context.sendDanmu({  
                    text: '要显示的弹幕文本',  
                    color: '#FF0000'  
                });  
            },  
            playbackRate() {  
                this.context.playbackRate(2);  
            }  
        }  
    }  
</script>  

<style>  
    .video {  
        width: 750rpx;  
        /* #ifdef H5 */  
        width: 100%;  
        /* #endif */  
        height: 400rpx;  
        background-color: #808080;  
    }  

    .btn {  
        margin-top: 5px;  
        margin-bottom: 5px;  
    }  
</style>  

操作步骤:

直接复制代码运行就行 本地视频 需要在本地文件夹放一个视频 如果是线上 把 :src="video.src" 改成 :src="src"

预期结果:

能够在指定的时间位置播放

实际结果:

不能够在指定的时间位置播放

bug描述:

video的 seek方法 是线上链接 跳转帧无问题 如果是本地视频 跳转帧 就会不准 经常会多几秒 少几秒

2021-02-24 11:23 负责人:无 分享
已邀请:
故里And长安

故里And长安

解决了吗?我也是这个问题

该问题目前已经被锁定, 无法添加新回复