x***@gmail.com
x***@gmail.com
  • 发布:2022-02-08 17:25
  • 更新:2022-02-08 18:16
  • 阅读:618

【报Bug】uniapp video在播放flv直播流文件时,android端出现加载就报error

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: win10

HBuilderX类型: 正式

HBuilderX版本号: 3.3.10

手机系统: Android

手机系统版本号: Android 10

手机厂商: 华为

手机机型: nova8

页面类型: vue

vue版本: vue2

打包方式: 云端

项目创建方式: HBuilderX

示例代码:
<video id="myVideo" :style="{ height: windowHeight + 'px' }" style="width: 100%;" src="zhibo.content" autoplay="true"
controls="false"
page-gesture="false" poster="zhibo.pic" enable-progress-gesture="false"
@error="videoErrorCallback" ></video>

操作步骤:

http://nineb.stewardship.cn/live/cx_10204.flv

预期结果:

出现无法播放时才报error

实际结果:

一加载立马报error, 十来秒之后无法播放再次报error, 在模拟器上不会出现加载立马报error的情况

bug描述:

在模拟器上正常, 在真机上加载直接报error

2022-02-08 17:25 负责人:无 分享
已邀请:
小枫叶

小枫叶 - 外包接单加v:wlmk1234567 注明来意

你给视频权限了么

x***@gmail.com

x***@gmail.com (作者)

能正常播放的也会出现一加载就报error的情况

DCloud_Android_DQQ

DCloud_Android_DQQ

你给个完整的示例。我试试

x***@gmail.com

x***@gmail.com (作者)

<template>  
    <video v-if="isshow" id="myVideo" :style="{ height: windowHeight + 'px' }" style="width: 100%;"  
            :src="zhiboInfo.content"  
            autoplay="true"  
            controls="false"  
            page-gesture="false"  
            :poster="zhiboInfo.pic"  
            enable-progress-gesture="false"  
            @error="videoErrorCallback" ></video>  
    <view class="shipinpic" v-else>  
        <image :src="bgpic" :style="{ height: windowHeight + 'px' }" style="width: 100%;"></image>  
        <view class="txt"><text>直播已结束</text></view>  
        <view class="guanzhu"><text>关注</text></view>  
        <view class="backzb" @click="goback()"><text>返回首页</text></view>  
    </view>  
</template>  
<script>  
    export default {  
        data() {  
            return {  
                zhiboInfo: {},  
                windowHeight: 0,  
                isshow: true,  
                zhiboId:0,  
                time: 0,  
                timer:null,  
                bgpic: "../../static/image/bg1.png"  
            };  
        },  
        onLoad(e) {  
            this.zhiboId = e.id;  
            this.loadData(e.id);  
        },  
        mounted: function (res) {  
            var that = this;  
            uni.getSystemInfo({  
                success: function (res) {  
                    that.windowHeight = res.windowHeight;  
                }  
            });  
        },  
        methods: {  
            loadData(zhiboId) {  
                this.$u.get('zhibo/detail', {zhiboId: zhiboId}).then(res => {  
                    if(res.data)  
                    {  
                        this.zhiboInfo = res.data;  
                        if(res.data.status == 0)  
                        {  
                            this.isshow = false;  
                        }                         
                    }else{  
                        this.$U.output('直播数据请求失败!');  
                    }  
                });  
                this.timer =setInterval(() => {  
                    this.time++;  
                }, 1000);  
            },  
            videoErrorCallback: function(e) {  
                if(this.time > 5)  
                {  
                    if (this.timer) clearInterval(this.timer);  
                    this.timer = null;  
                    this.time = 0;  
                    this.isshow = false;  
                }  
            }  
        }  
    };  
</script>  

<style>  
    template,page{background: #000000;}  
.shipinpic{width: 100%;}  
.txt{position:absolute;left: 300upx;top: 10%;color: #FFFFFF;z-index: 999;width: 200upx;text-align: center;}  
.guanzhu{position:absolute;left: 300upx;top: 50%;color: #F29100;z-index: 999;background: #FFFFFF;font-weight: bold;width: 200upx;height:60upx;border-radius: 22upx;text-align: center;line-height: 60upx;}  
.backzb{position:absolute;left: 300upx;bottom:5%;color: #FFFFFF;width: 200upx;height: 60upx;border-radius: 22upx;border: 1px solid #FFFFFF;text-align: center;font-weight: bold;line-height: 60upx;}  
</style>
  • x***@gmail.com (作者)

    我用了笨办法, 加了一个定时器, 判断超过5秒之后再出现error再判断为真正的加载失败

    2022-02-08 18:17

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