-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Audio Recording Visualization Not Working #30
Comments
Hi, I got the same error. did you got any solution? |
I found the solution by luck set backgroundColor="black" |
@Twathik Thank you for your help, you saved me from looking for a different plugin. But none of it is as good as this. |
you are welcome |
I have fought with this issue all day today and finally found an external fix and a suggestion for improving the library, @YZarytskyi. Please let me know how I can contribute, as this library is amazing, and this small enhancement would make it even better. Issue and suggested fix in the libraryThe canvas dimensions are being set before the component is fully rendered, leading to potential zero-width scenarios. This occurs in VoiceVisualizer.tsx#L168: useEffect(() => {
onResize(); // Executes before proper layout
...
}, [width, isAvailableRecordedAudio]); Proposed SolutionReplace the current resize handling with ResizeObserver for more reliable dimension management: // Use useLayoutEffect for initial dimensions
useLayoutEffect(() => {
if (!canvasContainerRef.current) return;
const resizeObserver = new ResizeObserver(() => {
onResize();
});
resizeObserver.observe(canvasContainerRef.current);
return () => resizeObserver.disconnect();
}, []); Benefits:
Current Workaround (what I am using right now)Until this is implemented, users can wrap the component with this solution:
Usage example:
Would you be interested in a pull request implementing this change? |
Hello, yes sure, you can contribute, I appreciate it |
- Remove window resize event listener - Implement ResizeObserver for more accurate dimension tracking - Move resize logic to useLayoutEffect for synchronous measurements - Add proper cleanup with observer disconnect - Fix initial render dimensions calculation BREAKING CHANGE: Removes window.resize event listener dependency Closes YZarytskyi#30
Done: #31 |
Describe the bug
The audio recording visualization is not working:
CleanShot.2024-12-19.at.07.06.49.mp4
To Reproduce
Source code here:
https://stackblitz.com/edit/react-voice-visualizer?file=src%2Fcomponents%2Fvoice-recorder.tsx
Expected behavior
Audio visualization when recording
Screenshots
If applicable, add screenshots to help explain your problem.
Package info (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: