Open
Description
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:
- Created a new nextjs app from cli.
- 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>
</>
);
}
- 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 />;
}
- Start recording and visualization not working.
- Playback works as expected.
Expected behavior
It should be working as given demo of the library.
Metadata
Metadata
Assignees
Labels
No labels