using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class record : MonoBehaviour
{
AudioClip audioClip;
AudioSource audioSource;
Use this for initialization
void Start()
{
string[] md = Microphone.devices;
int mdl = md.Length;
if (mdl == 0)
{
Debug.Log("no microphone found");
}
}
Update is called once per frame
//void Update () {
//}
public void StartRecordAudio()
{
audioSource = GameObject.Find("Canvas/Audio Source").GetComponent<AudioSource>();
Microphone.End(null);
audioClip = Microphone.Start(null, false, 30, 44100);
Debug.Log("开始录音.....");
}
public void StopRecordAudio()
{
Microphone.End(null);
}
public void PlayRecordAudio()
{
Microphone.End(null);
audioSource.clip = audioClip;
audioSource.Play();
}
public void EndPlayRecordAudio()
{
Microphone.End(null);
audioSource.Stop();
}
}