Skip to content

Visualization is not working while recording on NextJS #23

Open
@onurgenes

Description

@onurgenes

Visualization is not working while recording on NextJS. I have tried with the example from this repo 👉🏻 https://github.com/YZarytskyi/react-audio-visualization

To Reproduce
Steps to reproduce the behavior:

  1. Created a new nextjs app from cli.
  2. Added new component as following:
"use client";

import { Button } from "@/components/ui/button";
import React, { useEffect } from "react";
import { useVoiceVisualizer, VoiceVisualizer } from "react-voice-visualizer";

export default function VoiceRecorder() {
  const recorderControls = useVoiceVisualizer();
  const { saveAudioFile, recordedBlob, error } = recorderControls;

  // Get the recorded audio blob
  useEffect(() => {
    if (!recordedBlob) return;

    console.log(recordedBlob);
  }, [recordedBlob, error]);

  // Get the error when it occurs
  useEffect(() => {
    if (!error) return;

    console.error(error);
  }, [error]);

  return (
    <>
      <VoiceVisualizer
        controls={recorderControls}
        mainBarColor="#FFFFFF"
        secondaryBarColor="#5e5e5e"
        width={"100%"}
        height={200}
        speed={3}
        barWidth={2}
        gap={1}
        rounded={5}
        isControlPanelShown={true}
        isDownloadAudioButtonShown={true}
        fullscreen={false}
        onlyRecording={false}
        animateCurrentPick={true}
        isDefaultUIShown={true}
        isProgressIndicatorShown={true}
        isProgressIndicatorTimeShown={true}
        isProgressIndicatorOnHoverShown={true}
        isProgressIndicatorTimeOnHoverShown={true}
      />
      <Button onClick={saveAudioFile}>Save Audio</Button>
    </>
  );
}
  1. Import the component as dynamic for avoiding SSR issues:
"use client";

import dynamic from "next/dynamic";

const DynamicVoiceVisualizer = dynamic(
  () => import("@/components/voice-recorder"),
  {
    ssr: false,
  }
);

export default function Page() {
  return <DynamicVoiceVisualizer />;
}
  1. Start recording and visualization not working.
  2. Playback works as expected.

Expected behavior
It should be working as given demo of the library.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions