+
95
-

uniapp与没有模仿微信发送语音消息的代码?

uni
uniapp与没有模仿微信发送语音消息的代码?

网友回复

+
15
-

<template>
	<view class="audioPlay">
		<button @click="startRecord">开始录音</button>
		<button @tap="endRecord">停止录音</button> 
		<button @tap="playVoice">播放录音</button>
	</view>
</template>
<script>
	const recorderManager = uni.getRecorderManager();
	const innerAudioContext = uni.createInnerAudioContext();
	export default {
		data() {
			return {
				recorderManager: {},
				innerAudioContext: {},
				text: 'uni-app',
				voicePath: ''
			}
		},
		onLoad() {
			innerAudioContext.autoplay = true;
			console.log("uni.getRecorderManager()",uni.getRecorderManager())
			console.log("uni.createInnerAudioContext()",uni.createInnerAudioContext())
			let self = this;
			recorderManager.onStop(function (res) {
				console.log('recorder stop' + JSON.stringify(res));
				self.voicePath = res.tempFilePath;
			});
		    },
		    methods: {
		        startRecord() {
		   ...

点击查看剩余70%

我知道答案,我要回答