twilio-video.js icon indicating copy to clipboard operation
twilio-video.js copied to clipboard

Safari Participants cannot hear remote audio if they are not sharing local media.

Open manjeshbhargav opened this issue 3 years ago • 1 comments

Description:

Because of this WebKit bug, a user interaction is required to play back RemoteAudioTracks. As a workaround, you can prompt the user to click on a button so that your application can then play the paused <audio> elements as shown here.

Affected browsers and platforms:

  • [x] Browser(s): Safari
  • [x] Operating System: iOS, Mac

manjeshbhargav avatar Oct 23 '20 22:10 manjeshbhargav

Couple of observations on Safari/iOS (but may also apply to macOS) that may be useful for implementing a workaround.

We found that binding tracks in a click-handler worked as described, and that as long as an audio track continued playing, multiple tracks could start and stop just fine. However - we found that if you leave no RemoteAudioTracks playing for a short while, the audio playback permission appeared to be revoked and thus new audio tracks also failed to play. We managed to work around this by creating a dummy audio context that plays a buffer filled with zeroes on loop, thus keeping the audio permissions open. Not elegant, but working for now until we can find a better solution.

Comments/corrections/telling-me-that-this-is-a-bad-thing-to-do all welcome

Example Gist for workaround: https://gist.github.com/tr00st/845a8d4e72e94c0eb11f55fdc32b6446

Workaround based on the sample white noise generator in the MDN docs: https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode

tr00st avatar Apr 22 '21 10:04 tr00st