Oculus Go & Unity:麦克风实时回放
Oculus Go & Unity: Microphone Real-time Playback
我想通过扬声器实时播放来自 Oculus Go 麦克风的声音,但无法播放。我试过这段代码,它在编辑器中使用耳机的麦克风而不是 Oculus Go 时效果很好,或者我犯了一些错误?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
public class MicrophoneAudio : MonoBehaviour
{
void Start()
{
AudioSource micAudio = GetComponent<AudioSource>();
micAudio.clip = Microphone.Start(Microphone.devices[0], true, 10, 44100);
micAudio.loop = true;
while(!(Microphone.GetPosition(null) > 0)) { }
micAudio.Play();
}
}
或者这是设备限制?我已经观察了很多但没有运气,只发现没有实时播放的麦克风。希望有人能帮助我。:(
这个脚本应该可以在Oculus GO上运行,我在Oculus GO的音视频直播演示中使用了这个脚本。
AudioSource AudioMic;
void Start() {
StartCoroutine(CaptureMic());
}
IEnumerator CaptureMic()
{
if (AudioMic == null) AudioMic = GetComponent<AudioSource>();
AudioMic.clip = Microphone.Start(null, true, 1, OutputSampleRate);
AudioMic.loop = true;
while (!(Microphone.GetPosition(null) > 0)) { }
Debug.Log("Start Mic(pos): " + Microphone.GetPosition(null));
AudioMic.Play();
//capture for live streaming
//while (!stop)
//{
// AddMicData();
// yield return null;
//}
//capture for live streaming
yield return null;
}
我想通过扬声器实时播放来自 Oculus Go 麦克风的声音,但无法播放。我试过这段代码,它在编辑器中使用耳机的麦克风而不是 Oculus Go 时效果很好,或者我犯了一些错误?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
public class MicrophoneAudio : MonoBehaviour
{
void Start()
{
AudioSource micAudio = GetComponent<AudioSource>();
micAudio.clip = Microphone.Start(Microphone.devices[0], true, 10, 44100);
micAudio.loop = true;
while(!(Microphone.GetPosition(null) > 0)) { }
micAudio.Play();
}
}
或者这是设备限制?我已经观察了很多但没有运气,只发现没有实时播放的麦克风。希望有人能帮助我。:(
这个脚本应该可以在Oculus GO上运行,我在Oculus GO的音视频直播演示中使用了这个脚本。
AudioSource AudioMic;
void Start() {
StartCoroutine(CaptureMic());
}
IEnumerator CaptureMic()
{
if (AudioMic == null) AudioMic = GetComponent<AudioSource>();
AudioMic.clip = Microphone.Start(null, true, 1, OutputSampleRate);
AudioMic.loop = true;
while (!(Microphone.GetPosition(null) > 0)) { }
Debug.Log("Start Mic(pos): " + Microphone.GetPosition(null));
AudioMic.Play();
//capture for live streaming
//while (!stop)
//{
// AddMicData();
// yield return null;
//}
//capture for live streaming
yield return null;
}