日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

VUE使用benz-amr-recorder 实现解码、播放

發布時間:2023/12/18 65 豆豆
生活随笔 收集整理的這篇文章主要介紹了 VUE使用benz-amr-recorder 实现解码、播放 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

安裝

npm install benz-amr-recorder

引入

const BenzAMRRecorder = require('benz-amr-recorder')

使用

<template><div class="wx-voice-div" @click="playVoice(objData)"> </template>methods:{amrPlay(amr,obj){ //播放this.$set(obj, 'amrPlaying', true)amr.play()},amrStop(amr,val){// 停止(包括播放結束)this.$set(obj, 'amrPlaying', false)amr.stop()},playVoice(obj){this.getMaterialOther(obj.repMediaId , obj.repName).then(url => {this.$set(obj,'repUrl',url); //替換數據源中播放地址this.handleAudio(val)})},async getTempMaterialOther(repMediaId,fileName){ //獲取后臺返回的二進制文件let url;await this.ajax_get({url:this.$local+'crm/wxmaterial/tempMaterialOther', params:{mediaId: repMediaId,fileName: fileName}}).then(response => {url = window.URL.createObjectURL(new Blob([response])) //下載二進制文件到本地})return url},handleAudio(obj){this.$set(obj,'amr',new BenzAMRRecorder())let amr = obj.amrlet that = thisamr.initWithUrl(obj.repUrl).then(function() {that.amrPlay(amr, obj)that.$set(obj,'amrDuration',amr.getDuration())})amr.onEnded(function() {that.$set(obj, 'amrPlaying', false)//播放完了})} }

benz-amr-recorder詳細介紹

總結

以上是生活随笔為你收集整理的VUE使用benz-amr-recorder 实现解码、播放的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。