天天看點

vue 播放.amr語音檔案

别人在體驗人間的愛,而我在體驗人間的冷暖

前端QQ群: 981668406

我的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);
      }
    },


           

繼續閱讀