Skip to content
Advertisement

Combining audio and video tracks into new MediaStream

I need to get create a MediaStream using audio and video from different MediaStreams. In Firefox, I can instantiate a new MediaStream from an Array of tracks:

  var outputTracks = [];
  outputTracks = outputTracks.concat(outputAudioStream.getTracks());
  outputTracks = outputTracks.concat(outputVideoStream.getTracks());
  outputMediaStream = new MediaStream(outputTracks);

Unfortunately, this doesn’t work in Chrome:

ReferenceError: MediaStream is not defined

Is there an alternative method in Chrome for combining tracks from separate streams?

Advertisement

Answer

still vendor-prefixed with webkit:

  var outputTracks = [];
  outputTracks = outputTracks.concat(outputAudioStream.getTracks());
  outputTracks = outputTracks.concat(outputVideoStream.getTracks());
  outputMediaStream = new webkitMediaStream(outputTracks);
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement