8***@qq.com
8***@qq.com
  • 发布:2024-10-01 15:23
  • 更新:2024-10-07 12:02
  • 阅读:116

#插件讨论# 【 uniappx 录音和音频播放功能 - 小熊猫先生 】文档问题

分类:uni-app

您好,请问一文档地址吗?谢谢

2024-10-01 15:23 负责人:无 分享
已邀请:
小熊猫先生

小熊猫先生

<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
}
一共就这些api 这个是demo

要回复问题请先登录注册