Home Web Front-end uni-app How to implement recording function in uniapp

How to implement recording function in uniapp

Dec 09, 2020 pm 02:44 PM
uniapp recording function

Uniapp implements the recording function: Use the function [uni.getRecorderManager()] to implement, the code is [methods: {startRecord() {console.log('Start recording'); this.recorderManager].

How to implement recording function in uniapp

The operating environment of this tutorial: windows7 system, uni-app2.5.1 version, Dell G3 computer.

How uniapp implements the recording function:

You need to use this paragraph 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();
}
},
}
}
Copy after login

The Apple phone cannot be played when the phone is muted

uni.setInnerAudioOption({  
obeyMuteSwitch: false  
})
Copy after login

The recording shown here uses the plug-in luno-audio,

Recommended (free): uni-app development tutorial

You need to introduce import luchAudio from '@/components/luch-audio/luch-audio.vue' and register (just register in components ) and use

<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>
Copy after login

to add it and run it.

Related free learning recommendations: Programming videos

The above is the detailed content of How to implement recording function in uniapp. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Where can I find the recording function on Apple? Where can I turn on the recording function on my iPhone? Where can I find the recording function on Apple? Where can I turn on the recording function on my iPhone? Feb 22, 2024 pm 02:52 PM

After entering the voice memo, you can record through the red round icon. Tutorial Applicable Model: iPhone13 System: iOS15.3 Analysis 1 First open the phone, find and click Voice Memo. 2After entering the recording page, click the red circular icon to start recording. 3Click the red circular icon again to pause recording. 4Finally click Finish to save. Supplement: Where are the recording files on Apple phones? 1. First open the phone and slide the screen to enter the negative screen. 2After entering voice memo in the top search bar, click the search result. 3After entering the recording page, you can view all recording files. Summary/Notes The recorded part can be played back when recording is paused.

How to start preview of uniapp project developed by webstorm How to start preview of uniapp project developed by webstorm Apr 08, 2024 pm 06:42 PM

Steps to launch UniApp project preview in WebStorm: Install UniApp Development Tools plugin Connect to device settings WebSocket launch preview

Which one is better, uniapp or mui? Which one is better, uniapp or mui? Apr 06, 2024 am 05:18 AM

Generally speaking, uni-app is better when complex native functions are needed; MUI is better when simple or highly customized interfaces are needed. In addition, uni-app has: 1. Vue.js/JavaScript support; 2. Rich native components/API; 3. Good ecosystem. The disadvantages are: 1. Performance issues; 2. Difficulty in customizing the interface. MUI has: 1. Material Design support; 2. High flexibility; 3. Extensive component/theme library. The disadvantages are: 1. CSS dependency; 2. Does not provide native components; 3. Small ecosystem.

Where is the recording function of Apple mobile phone? Where is the recording function of Apple mobile phone? Mar 08, 2024 pm 02:00 PM

Users want to use the recording function on their Apple phones, but don't know how to turn on the recording. It's actually very simple. You can find the voice memo button by entering the control center, and click it to enter the phone's recording function. Where is the recording function of Apple's mobile phone? Answer: You can turn on mobile phone recording in the control center. 1. If a user wants to perform mobile phone recording on an Apple mobile phone, he or she needs to turn on the voice memo function in the phone. 2. The fastest way to open a voice memo is to open it in the control center. Click to use it directly. 3. You can also find the voice memo in the software library that comes with the system on the desktop and click to use it. 4. The voice memo function can be uninstalled. If the user accidentally uninstalls the related software, it can be re-downloaded from the app store. 5. If

What development tools do uniapp use? What development tools do uniapp use? Apr 06, 2024 am 04:27 AM

UniApp uses HBuilder

How to turn on the recording function of Apple mobile phone_How to turn on the recording function of Apple mobile phone How to turn on the recording function of Apple mobile phone_How to turn on the recording function of Apple mobile phone Mar 23, 2024 pm 07:10 PM

1. First, find and open Voice Memos on the iPhone desktop and select all recordings. 2. Then, click the red button to start recording the voice memo, and click the red button again to pause the recording.

What basics are needed to learn uniapp? What basics are needed to learn uniapp? Apr 06, 2024 am 04:45 AM

uniapp development requires the following foundations: front-end technology (HTML, CSS, JavaScript) mobile development knowledge (iOS and Android platforms) Node.js other foundations (version control tools, IDE, mobile development simulator or real machine debugging experience)

What are the disadvantages of uniapp What are the disadvantages of uniapp Apr 06, 2024 am 04:06 AM

UniApp has many conveniences as a cross-platform development framework, but its shortcomings are also obvious: performance is limited by the hybrid development mode, resulting in poor opening speed, page rendering, and interactive response. The ecosystem is imperfect and there are few components and libraries in specific fields, which limits creativity and the realization of complex functions. Compatibility issues on different platforms are prone to style differences and inconsistent API support. The security mechanism of WebView is different from native applications, which may reduce application security. Application releases and updates that support multiple platforms at the same time require multiple compilations and packages, increasing development and maintenance costs.

See all articles