creating the spatial audio webpage

PHOTO EMBED

Fri Feb 26 2021 20:18:22 GMT+0000 (UTC)

Saved by @surrealemily

async function connectToHiFiAudio() {
    let audioMediaStream;
    try {
        audioMediaStream = await navigator.mediaDevices.getUserMedia({ audio: HighFidelityAudio.getBestAudioConstraints(), video: false });
    } catch (e) {
        return;
    }
    let initialHiFiAudioAPIData = new HighFidelityAudio.HiFiAudioAPIData({
        position: new HighFidelityAudio.Point3D({ "x": 0, "y": 0, "z": 0 }),
        orientationEuler: new HighFidelityAudio.OrientationEuler3D({ "pitch": 0, "yaw": 0, "roll": 0 })
    });
    let hifiCommunicator = new HighFidelityAudio.HiFiCommunicator({
        transmitRateLimitTimeoutMS: 10,
        initialHiFiAudioAPIData: initialHiFiAudioAPIData
    });
    await hifiCommunicator.setInputAudioMediaStream(audioMediaStream);
    const HIFI_AUDIO_JWT = "MY_HIFI_AUDIO_JWT"; // TODO: Replace with a test JWT - https://www.highfidelity.com/api/guides/misc/getAJWT
    try {
        await hifiCommunicator.connectToHiFiAudioAPIServer(HIFI_AUDIO_JWT);
    } catch (e) {
        console.error(`Error connecting to High Fidelity:\n${e}`);
        return;
    }

    // TODO: Send position updates to hifiCommunicator
}
content_copyCOPY