t-mullen / video-stream-merger

Merge multiple video MediaStreams into one composite.
https://t-mullen.github.io/video-stream-merger/
MIT License
357 stars 81 forks source link

Safari 14 support. #64

Open stijndeschuymer opened 3 years ago

stijndeschuymer commented 3 years ago

Hi, Thanks for your great library. I noticed the following: This line fails in Safari 14: https://github.com/t-mullen/video-stream-merger/blame/cf54b5fe3bc4f5624d719b064874e615757c8a12/src/index.js#L61

So either this needs to be added to the audioSupport check https://github.com/t-mullen/video-stream-merger/blob/gh-pages/src/index.js#L11

But I'd prefer to fix this _backgroundAudioHack function. maybe createConstantSource() could be replaced by AudioContext.createOscillator() ? Wdyt?

Thanks!

gut4 commented 3 years ago

https://github.com/chrisguttandin/standardized-audio-context Maybe this can help?

hthetiot commented 3 years ago

Fixed by #71 , I can do separate PR if needed


_createConstantSource() {

    if (this._audioCtx) {
      if (this._audioCtx.createConstantSource) {
        return this._audioCtx.createConstantSource();
      }

      // not really a constantSourceNode, just a looping buffer filled with the offset value
      const constantSourceNode = this._audioCtx.createBufferSource();
      const constantBuffer = this._audioCtx.createBuffer(1, 1, this._audioCtx.sampleRate);
      const bufferData = constantBuffer.getChannelData(0);
      bufferData[0] = (0 * 1200) + 10;
      constantSourceNode.buffer = constantBuffer;
      constantSourceNode.loop = true;

      return constantSourceNode;
    }
  }
hthetiot commented 3 years ago

Fixing createConstantSource and moving canvas creation to start did the trick.

hthetiot commented 3 years ago

Fixed in 4.0.0 release.

t-mullen commented 3 years ago

@stijndeschuymer Please close this issue if it is solved in 4.0.1