uni-app 【报Bug】plus.video.createVideoPlayer的video.show() 没有效果

uni-app 【报Bug】plus.video.createVideoPlayer的video.show() 没有效果

信息类别 详细信息
产品分类 uniapp/App
PC开发环境操作系统 Windows
PC开发环境操作系统版本号 win10
HBuilderX类型 正式
HBuilderX版本号 3.2.2
手机系统 Android
手机系统版本号 Android 7.0
手机厂商 電視盒子
手机机型 電視盒子
页面类型 vue
打包方式 云端
项目创建方式 HBuilderX

示例代码:

videoPlayer() {  
    this.video = plus.video.createVideoPlayer('video', {  
        src: 'https://aweme.snssdk.com/aweme/v1/playwm/?s_vid=93f1b41336a8b7a442dbf1c29c6bbc56ed36a264deeb0dbd7de34f2461f611992c7461fbd5d74f19fefee7b486937eb0f02f51f0a2c565611a8647508c79e643&line=0',  
        top: '0px',  
        left: '0px',  
        width: '300px',  
        height: '200px',  
        'poster': 'https://p9.pstatp.com/large/tos-cn-p-0015/98750838e6834083a5301fb7c43f751d_1584966810.jpg',  
        position: 'absolute',  
        'direction': 0, //全屏方向正常竖向  
        'enable-danmu': true, //展示弹幕  
        'danmu-btn': true, //是否显示弹幕按钮  
        'show-progress': false, //显示播放进度条  
        'enable-progress-gesture': false, //是否开启进度手势  
    });  
    plus.webview.currentWebview().append(this.video);  
    this.video.show();  
},

操作步骤:

運行後,沒有video播放出來
使用this.video.show();
或
this.video.play();
都是沒有效果的.  

但使用了this.video.requestFullScreen();
就可以播放(但我不是要全屏播放呀...)

预期结果:

有video播放出來

实际结果:

運行後,沒有video播放出來

bug描述:

運行後,沒有video播放出來

更多关于uni-app 【报Bug】plus.video.createVideoPlayer的video.show() 没有效果的实战教程也可以访问 https://www.itying.com/category-93-b0.html

1 回复

更多关于uni-app 【报Bug】plus.video.createVideoPlayer的video.show() 没有效果的实战教程也可以访问 https://www.itying.com/category-93-b0.html


根据您提供的代码和描述,这是一个典型的原生视频播放器创建后未正确显示的问题。主要原因在于视频播放器创建后,虽然已附加到当前Webview,但未正确触发其显示流程。

问题分析:

  1. plus.video.createVideoPlayer 创建的是原生视频播放器控件
  2. append() 方法将播放器添加到当前页面
  3. show() 方法理论上应该显示播放器,但在某些Android设备(特别是电视盒子)上可能存在兼容性问题

解决方案:

方案一:延迟显示(推荐)

videoPlayer() {  
    this.video = plus.video.createVideoPlayer('video', {  
        src: 'https://aweme.snssdk.com/aweme/v1/playwm/?s_vid=93f1b41336a8b7a442dbf1c29c6bbc56ed36a264deeb0dbd7de34f2461f611992c7461fbd5d74f19fefee7b486937eb0f02f51f0a2c565611a8647508c79e643&line=0',  
        top: '0px',  
        left: '0px',  
        width: '300px',  
        height: '200px',  
        'poster': 'https://p9.pstatp.com/large/tos-cn-p-0015/98750838e6834083a5301fb7c43f751d_1584966810.jpg',  
        position: 'absolute',  
        'direction': 0,
        'enable-danmu': true,
        'danmu-btn': true,
        'show-progress': false,
        'enable-progress-gesture': false,
    });  
    
    plus.webview.currentWebview().append(this.video);  
    
    // 添加延迟确保DOM渲染完成
    setTimeout(() => {
        this.video.show();
        this.video.play();
    }, 100);
},

方案二:使用play()方法自动触发显示

videoPlayer() {  
    this.video = plus.video.createVideoPlayer('video', {  
        // ... 参数同上
    });  
    
    plus.webview.currentWebview().append(this.video);  
    
    // 直接调用play(),通常会自动触发显示
    this.video.play();
},

方案三:检查视频源格式 电视盒子设备可能对视频格式有特定要求。尝试更换为标准的MP4格式视频源进行测试:

src: 'http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4', // 测试用标准MP4
回到顶部