Combining audio and video tracks into new MediaStr

2020-04-02 17:47发布

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?

1条回答
戒情不戒烟
2楼-- · 2020-04-02 18:51

still vendor-prefixed with webkit:

  var outputTracks = [];
  outputTracks = outputTracks.concat(outputAudioStream.getTracks());
  outputTracks = outputTracks.concat(outputVideoStream.getTracks());
  outputMediaStream = new webkitMediaStream(outputTracks);
查看更多
登录 后发表回答