vue 播放.amr语音文件

2021-05-25  本文已影响0人  魔仙堡杠把子灬

别人在体验人间的爱,而我在体验人间的冷暖

我的github: 李大玄
我的私人博客: 李大玄
我的npm开源库: 李大玄
我的简书: 李大玄
我的CSDN: 李大玄
我的掘金: 李大玄
哔哩哔哩: 李大玄

npm i benz-amr-recorder

import BenzAMRRecorder from 'benz-amr-recorder';

const list = [{ossFileUrl: 'xxxxxxxxxxx'},{ossFileUrl: 'xxxxxxxxxxx'},{ossFileUrl: 'xxxxxxxxxxx'},];

audioPlay(data) {
      if (!data.isPlay) {
        const url = data.ossFileUrl;
        this.amr = new BenzAMRRecorder();
        this.$set(data, 'isPlay', true);
        this.amr.initWithUrl(url).then(() => {
          this.amr.play();
        });
        this.amr.onEnded(() => { // 播放结束重置状态
          this.$set(data, 'isPlay', false);
        });
      } else {
        this.amr.stop();
        this.$set(data, 'isPlay', false);
      }
    },


上一篇 下一篇

猜你喜欢

热点阅读