HomeDocs
Skip to main content

RecorderManager.onStop(function listener)

Introduction

This function is used to listen for the recording end event.

Usage Limitations

Supported in the basic library version 4.0.0 or higher.

Parameters

  • function listener: A callback function to handle the recording end event.

Callback Parameters

  • Object res: An object containing the following properties:
    • tempFilePath (string): The temporary file path of the recorded audio (local path).
    • duration (number): The total duration of the recording in milliseconds.
    • fileSize (number): The size of the recording file in bytes.

Example Code

// pages/index/index.js

Page({
onStop() {
const recorderManager = dlt.getRecorderManager();

recorderManager.onStop((res) => {
console.log('Recording stopped', res.tempFilePath);
});

recorderManager.stop();
},
});

In this example, the RecorderManager.onStop method is used to set up a listener for the recording end event. When the recording ends, it triggers the callback function and provides information about the recorded audio, including the temporary file path, total duration, and file size. The console.log statement in the callback function logs the temporary file path of the recorded audio. Additionally, recorderManager.stop() is used to stop the recording.

Privacy agreementDeveloper agreementcontact us: developer_service.mi@transsion.com © 2024 MiniApp. All Rights Reserved.