kixelated / moq-js

Typescript library for Media over QUIC
Apache License 2.0
143 stars 32 forks source link

AudioWorkletProcessor is not defined #114

Open rmallick6806 opened 2 months ago

rmallick6806 commented 2 months ago

Trying to set up a simple playback in React. Here is the code:

const MoqPlayerDiv = styled.div`
  .root-theme-light & {
    background-color: #f5f5f5;
    color: #00000060;
  }
  .root-theme-dark & {
    background-color: #292929;
    color: #ffffff60;
  }
`;

/**
 * Moq Player
 **/

interface MoqPlayerProps {}

export function MoqPlayer(props: MoqPlayerProps) {
  const canvasRef = useRef<HTMLCanvasElement>(null);
  const [player, setPlayer] = useState<Player | undefined>();
  const [error, setError] = useState<Error | undefined>();

  useEffect(() => {
    const config = {
      url: 'redacted',
      fingerprint: 'redacted',
    };
    const namespace = 'test';

    Player.create({
      url: config.url,
      fingerprint: config.fingerprint,
      element: canvasRef.current,
    })
      .then(setPlayer)
      .catch(setError);
  });

  return (
    <MoqPlayerDiv>
      <canvas
        ref={canvasRef}
        className="aspect-video w-full rounded-lg"
        onClick={() => console.log('play')}
      />
    </MoqPlayerDiv>
  );
}

However, no matter what, I get the error AudioWorkletProcessor is not defined. What is the solution?