123456789101112131415161718 |
- export function playAudio(type){
- const innerAudioContext = uni.createInnerAudioContext();
-
- innerAudioContext.src = '/static/'+type+'.mp3';
- innerAudioContext.onCanplay(res => {
- innerAudioContext.play()
- })
- innerAudioContext.onPlay(() => {
- console.log('开始播放');
- });
- innerAudioContext.onError((res) => {
- console.log(res.errCode);
- });
- innerAudioContext.onEnded(res => {
- innerAudioContext.destroy()
- })
- }
|