TwilioDevEd / client-quickstart-js-deprecated

Twilio Client Quickstart for Web/Javascript
MIT License
46 stars 48 forks source link

Adding a sound to the call via a button click #7

Open johneakin opened 5 years ago

johneakin commented 5 years ago

Hi, I have added a button onto this quick start. I want to add a sound to the call when I click the button:

So far I have been unable to get this working:

document.getElementById('button-play').onclick = function () { var context = new (window.AudioContext || window.webkitAudioContext)(); var destination = context.createMediaStreamDestination(); var oscillator = context.createOscillator(); oscillator.type = 'sine'; oscillator.frequency.value = 440; oscillator.connect(destination); var mediaStreamTrack = destination.stream.getAudioTracks()[0]; conn.getLocalStream().addTrack(mediaStreamTrack);
oscillator.start() };

Any help is appreciated thanks