返回介绍

Microphone.Start 开始

发布于 2019-12-18 15:38:02 字数 2665 浏览 971 评论 0 收藏 0

JavaScript => public static function Start(deviceName: string, loop: bool, lengthSec: int, frequency: int): AudioClip;
C# => public static AudioClip Start(string deviceName, bool loop, int lengthSec, int frequency);

Parameters 参数

deviceNameThe name of the device.
loopIndicates whether the recording should continue recording if lengthSec is reached, and wrap around and record from the beginning of the AudioClip.
lengthSecIs the length of the AudioClip produced by the recording.
frequencyThe sample rate of the AudioClip produced by the recording.

Returns

AudioClip The function returns null if the recording fails to start.

Description 描述

Start Recording with device.

设备开始记录。

If you pass a null or empty string for the device name then the default microphone will be used. You can get a list of available microphone devices from the devices property. You can find the range of sample rates supported by a microphone using the GetDeviceCaps property.

如果你传递一个无效或者空的设备名称那么默认麦克风将会被使用。你可以从设备属性获取可用麦克风设备列表。你可以使用GetDeviceCaps 属性获取支持的样本比率的范围。

Note that if you want to use the Microphone class in the web player, you need to get the user's permission to do so. Call Application.RequestUserAuthorization before calling any Microphone methods.

注意如果你行在网页播放器上使用麦克风类,你需要获取用户许可才能够那么做。在调用任何麦克风方法之前调用Application.RequestUserAuthorization。

JavaScript:

// Start recording with built-in Microphone and play the recorded audio right away
function Start() {
	var aud = GetComponent.<AudioSource>();
	aud.clip = Microphone.Start("Built-in Microphone", true, 10, 44100);
	aud.Play();
}

C#:

using UnityEngine;
using System.Collections;
 
public class ExampleClass : MonoBehaviour {
    void Start() {
        AudioSource aud = GetComponent<AudioSource>();
        aud.clip = Microphone.Start("Built-in Microphone", true, 10, 44100);
        aud.Play();
    }
}

microphone

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文