AddTrack to MediaStream not working

485 views
Skip to first unread message

John Eakin

unread,
Dec 27, 2018, 2:36:10 AM12/27/18
to discuss-webrtc
Hi,
I am using twilio and get the MediaStream via the Twilio getLocalStream function. If I alter this I should be able to hear this on the Twilio call.

I want to add some audio to the stream, as a test I am using oscillator. Code runs without errors but I don't hear the noise on the call. Does the below look accurate?

document.getElementById('button-play').onclick = function () {
log('Play sound');
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];
myConnection.getLocalStream().addTrack(mediaStreamTrack);
oscillator.start();
};

John Eakin

unread,
Dec 29, 2018, 5:20:32 AM12/29/18
to discuss-webrtc
Bump

Philipp Hancke

unread,
Dec 29, 2018, 5:48:10 AM12/29/18
to discuss...@googlegroups.com
you're adding the track to the mediastream but probably not to the peerconnection (if twilio still uses addStream that might actually work due to a quirk in Chrome)? chrome://webrtc-internals might give hints about what happens.

Am Sa., 29. Dez. 2018 um 11:20 Uhr schrieb John Eakin <johne...@gmail.com>:
Bump

--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/38551f82-78dc-4840-aa7a-4533633a5957%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

John Eakin

unread,
Dec 29, 2018, 6:09:26 AM12/29/18
to discuss-webrtc
It doesn't work in chrome or Edge.
I suspect that MediaStream should already be added to the peer connection as the microphone connection works on the call.

I just can't play a sound on it.
I'll maybe have to raise a ticket with Twilio.
Just wanted to make sure how I was adding the sound to the MediaStream was correct.

Reply all
Reply to author
Forward
0 new messages