Chudovische

Untitled

Jun 11th, 2021
765
1 day
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. try {
  2.   await hifiCommunicator.connectToHiFiAudioAPIServer(HIFI_AUDIO_JWT);
  3. } catch (e) {
  4.   console.error(`Error connecting to High Fidelity:\n${e}`);
  5.   connectButton.disabled = false;
  6.   connectButton.innerHTML = `Connection error. Retry?`;
  7.   return;
  8. }
  9.  
  10. // Show the user that we're connected by changing the text on the button.
  11. connectButton.innerHTML = `Connected!`;
  12.  
  13. // Set the `srcObject` on our `audio` DOM element to the final, mixed audio stream from the High Fidelity Audio API Server.
  14. document.querySelector(`.outputAudioEl`).srcObject = hifiCommunicator.getOutputAudioMediaStream();
  15. // We explicitly call `play()` here because certain browsers won't play the newly-set stream automatically.
  16. document.querySelector(`.outputAudioEl`).play();
RAW Paste Data