InnerAudioContext.onError

2020-08-26 16:28 更新

解释:音频播放错误事件

方法参数

Function callback

示例 

在开发者工具中打开


图片示例

代码示例

<view class="wrap">
    <view class="card-area">
        此页面遇到音频播放错误事件会弹窗提示
    </view>
</view>
Page({
    onLoad() {
        const innerAudioContext = swan.createInnerAudioContext();
        innerAudioContext.src = 'https://b.bdstatic.com/miniapp/images/yanyuan.mp3';
        innerAudioContext.autoplay = false;
        innerAudioContext.onPlay(res => {
            swan.showToast({
                title: 'onplay',
                icon: 'none'
            });
        });
        innerAudioContext.onError(err => {
            swan.showModal({
                title: 'onError',
                content: JSON.stringify(err)
            });
            console.log('onError', err);
        });
        innerAudioContext.play();
        this.innerAudioContext = innerAudioContext;
    }
});


以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号