uni-app开发过程中电话录音的问题

uni-app开发的app无法实现电话通话过程中的双向录音

IOS、Android

利用uni-app自带的录音函数,只能实现己方声音的录音,对方的声音录不到?

我想要实现电话通话双方的录音,请各位帮帮忙,困惑了好久了!

应该要另外使用IOS、Android的原生代码编写这个功能,然后uni-app调起原生代码,uni-app只是一个ui框架,要想实现这种与系统或硬件相关的需求,还得是原生开发好


这是一个路由的例子,但是录音是属于隐私问题,需要授权的

没有解决我的问题,但是依然感谢楼上三位的解答,奖金会分配给大家!!
如果大家有完美的解决方案,希望跟我联系,另外给予奖励!

uniapp实现录音功能的方法:使用函数【uni.getRecorderManager()】实现,代码为【methods: {startRecord() {console.log('开始录音');this.recorderManager】。



本教程操作环境:windows7系统、uni-app2.5.1版本,Dell G3电脑。

uniapp实现录音功能的方法:

这里就需要用到uni.getRecorderManager()









































export default {

data: {

recorderManager: {},

innerAudioContext: {},

},

onLoad(options) {

this.recorderManager = uni.getRecorderManager();

this.innerAudioContext = uni.createInnerAudioContext();

// 为了防止苹果手机静音无法播放

uni.setInnerAudioOption({  

obeyMuteSwitch: false  

})

this.innerAudioContext.autoplay = true;

console.log("uni.getRecorderManager()",uni.getRecorderManager())

let self = this;

this.recorderManager.onStop(function (res) {

console.log('recorder stop' + JSON.stringify(res));

self.voicePath = res.tempFilePath;

});

},

methods: {

startRecord() {

console.log('开始录音');

this.recorderManager.start();

},

endRecord() {

console.log('录音结束');

this.recorderManager.stop();

},

playVoice() {

console.log('播放录音');

console.log('this.voicePath',this.voicePath);

  

if (this.voicePath) {

this.innerAudioContext.src = this.voicePath;

this.innerAudioContext.play();

}

},

}

}

这一段是苹果手机静音时无法播放




uni.setInnerAudioOption({  

obeyMuteSwitch: false  

})

这里录音展示是使用了插件luno-audio,

推荐(免费):uni-app开发教程

需要引入import luchAudio from '@/components/luch-audio/luch-audio.vue'、注册(在components内注册即可)并使用











<view class="audioPlay">

<button @tap="startRecord">开始录音</button>

<button @tap="endRecord">停止录音</button> 

<button @tap="playVoice">播放录音</button>

</view>

<luch-audio 

v-if="audioContent"

:src="audioContent"

:play.sync="audioPlayNew"

></luch-audio>

添加后运行即可。