Expo-AV not playing audio after a while, and how to fix it
08/28/2024 08:36
Recently, I was working on my game AI Against Humanity, where I encountered a bug in Expo-AV.
Namely, I was trying to play sounds.
And while it at first worked fine, after playing sounds for a few minutes, eventually I would run into this issue:
This was due to a memory leak in my application.
When you load sounds with await Audio.Sound.createAsync(source), it doesn't automatically unload it.
So I just wrote a custom hook, useSoundEffect, that you can use out of the box in your Expo app as well.
Here it is:
It's supposed to be used like this:
That's about it for now, I'll see you soon
With love from wituz
0
0
Write a reply (0/3500)
Replies
No replies yet