Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix returnAudio #3

Open
nanosonde opened this issue Jan 2, 2021 · 2 comments
Open

Fix returnAudio #3

nanosonde opened this issue Jan 2, 2021 · 2 comments

Comments

@nanosonde
Copy link

nanosonde commented Jan 2, 2021

With this I got returnAudio working:

  session.on("peerconnection", () => {
      session.connection.addEventListener("track", (e) => {
          console.log('adding audio track')
          // set remote audio track (to listen to remote audio)
          // remoteAudio is <audio> element on page
          const remoteAudio = document.querySelector('audio');
          remoteAudio.srcObject = e.streams[0];
          remoteAudio.play();
      })
  });  
@nanosonde
Copy link
Author

nanosonde commented Jan 2, 2021

Here you wrote that you did not get it working with the "track" event:

//Note: Was not able to get session.connection.ontrack = function(e) to work
session.connection.onaddstream = function(e) {
console.log('Outoing - addstream');
remoteAudio.srcObject = e.stream;
remoteAudio.play();
};

The key here is to use remoteAudio.srcObject = e.streams[0] and not remoteAudio.srcObject = e.stream.

This here needs to be changed too accordingly:

session.on("peerconnection", () => {
session.connection.addEventListener("addstream", (e) => {
console.log('Incoming - adding audiostream')
remoteAudio.srcObject = e.stream;
remoteAudio.play();
})
});

@nanosonde
Copy link
Author

With the above changes I was able to get full duplex audio on my iPad with iPadOs 14.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant