tommyjlong / doorvivint-card

Home Assistant Video Doorbell Card for Vivint Doorbell
Other
19 stars 9 forks source link

Fix returnAudio #3

Open nanosonde opened 3 years ago

nanosonde commented 3 years ago

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 commented 3 years ago

Here you wrote that you did not get it working with the "track" event: https://github.com/tommyjlong/doorvivint-card/blob/44ba38bf660c7f2ea4e0447c1a609c425e653a6f/dist/doorvivint-card.js#L235-L240

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

This here needs to be changed too accordingly: https://github.com/tommyjlong/doorvivint-card/blob/44ba38bf660c7f2ea4e0447c1a609c425e653a6f/dist/doorvivint-card.js#L173-L179

nanosonde commented 3 years ago

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