美文网首页
vue 播放.amr语音文件

vue 播放.amr语音文件

作者: 魔仙堡杠把子灬 | 来源:发表于2021-05-25 09:58 被阅读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);
      }
    },


相关文章

网友评论

      本文标题:vue 播放.amr语音文件

      本文链接:https://www.haomeiwen.com/subject/ipeqsltx.html