我使用innerAudioContext 对象创建了一个音频,在vue组件的onload里面,模仿的官方的hello-uniapp,能够创建成功,也能够播放,但是会报错,onPlay和onEnded等方法都不能用
先定义了一个var music = null;
onLoad:function(){
music = uni.createInnerAudioContext();
music.onPlay(() => {
console.log('开始播放');
});
},
在methods里面使用
openMusic: function(res) {
if (!this.isPlaying) {
music.src = res;
music.play();
this.isPlaying = true;
}
},
页面会报错
[system] errorHandler TypeError: Cannot read property 'onPlay' of undefined
at t.c.(:8080/apph5/anonymous function) [as onPlay] (http://192.168.17.198:8080/apph5/index.js:3082:101479)
at VueComponent.onLoad (talk-detail.vue:86)
at o (index.umd.min.js:1)
at s (index.umd.min.js:1)
at VueComponent.created (index.umd.min.js:1)
at callHook (vue.runtime.esm.js:2968)
at VueComponent.Vue._init (vue.runtime.esm.js:4710)
at new VueComponent (vue.runtime.esm.js:4876)
at createComponentInstanceForVnode (vue.runtime.esm.js:4376)
at init (vue.runtime.esm.js:4203) VueComponent {_uid: 58, _isVue: true, $options: {…}, _renderProxy: Proxy, _self: VueComponent, …} created hook
在线等,急
z***@163.com
uni.getRecorderManager(),录音管理器暂停方法不能使用啊
2019-12-22 22:13