更新记录

1.0.9(2024-11-04)

导出medaData

1.0.8(2024-10-08)

修改插件名称

1.0.7(2024-10-08)

更新版本

查看更多

平台兼容性

Vue2 Vue3
App 快应用 微信小程序 支付宝小程序 百度小程序 字节小程序 QQ小程序
HBuilderX 4.24,Android:7.0,iOS:9,HarmonyOS:不确定 × × × × × ×
钉钉小程序 快手小程序 飞书小程序 京东小程序
× × × ×
H5-Safari Android Browser 微信浏览器(Android) QQ浏览器(Android) Chrome IE Edge Firefox PC-Safari
× × × × × × × × ×
<template>
    <view>
        <button @click="start">开始录音</button>
        <button @click="pause">暂停录音</button>
        <button @click="resume">继续录音</button>
        <button @click="stop">停止录音</button>
        <button @click="playaudio">开始播放</button>
        <button @click="pauseaudio">暂停播放</button>
        <button @click="stopaudio">停止播放</button>
    </view>
</template>

<script>
    import {startRecording,MyApiOptions,stopRecording,resumeRecording,pauseRecording,playAudio,pauseAudio,PlayAudioOptions,stopAudio} from "../../uni_modules/p-audioManager"
    export default {
        data() {
            return {
                title: 'Hello',
                audioUrl:""
            }
        },
        onLoad() {

        },
        methods: {
            stop() {
                stopRecording({
                    success: (res) => {
                        console.log(res);
                        this.audioUrl = res.data!.url as string;
                    }
                }as MyApiOptions);
            },
            pause() {
                pauseRecording();
            },
            resume() {
                resumeRecording();
            },
            start() {
                startRecording({
                    success: (res) => {
                        console.log(res.code)
                        console.log(res.msg)
                    }
                } as MyApiOptions);
            },
            playaudio() {
                playAudio({
                     path:this.audioUrl,
                     success: (res) => {
                         console.log(res);
                     }
                } as PlayAudioOptions);
            },
            pauseaudio() {
                pauseAudio();
            },
            stopaudio() {
                stopAudio();
            }
        }
    }
</script>

<style>

</style>

//android 返回内容
//‍[⁠MyApiResult⁠]‍
{
    "code":
        //‍[number]‍
        0,
    "data":
    //‍[⁠UTSJSONObject⁠]‍
    {
        "duration":
            //‍[number]‍
            2.137,
        "url": "/storage/emulated/0/Android/data/uni.UNI0FAD805/files/audioManager/317531c6-b10f-4f5b-8763-4b9d66536aae.mp3"
    },
    "msg": "结束录音"
}
//ios 返回内容
{
    "msg": "结束录音",
    "code": 0,
    "data": {
        "url": "file:///Users/pengyuele/Library/Developer/CoreSimulator/Devices/05530AF6-BD1B-451F-A239-1095B5AE09BB/data/Containers/Data/Application/42564B6E-50DD-4D01-B054-88F42A0D041C/Documents/6183D4FD-BD70-4E71-BBD0-9E6374BCDF3E.m4a",
        "duration": 0
    }
}

android playAudio 返回内容
{code: 0, data: null, msg: "开始播放"}
{code: 0, data: null, msg: "播放完成"}

ios playAudio 返回内容
{
    "msg": "开始播放",
    "code": 0
}
{
    "msg": "播放完成",
    "code": 0
}

隐私、权限声明

1. 本插件需要申请的系统权限列表:

<uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问