-
Notifications
You must be signed in to change notification settings - Fork 36
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
Finish playing before destroying the sound currently playing #128
Comments
@AlesSrsen interesting use case, but this makes sense to me. It sounds almost like a good case for useGlobalAudioPlayer but as you mentioned this only supports one sound. Perhaps we could update the API to allow for multiple global sounds to be created/started? What do you think? Also, I won't have as much bandwidth as I had earlier this year. If this is something you're open to collabing on in the form of a PR, feel free to get started on one or starting a back and forth here where we can at least discuss the solution options. |
@E-Kuerschner I actualy did something different in the end. It is not the best practice but I created a new Audio object in the global scope, that I control with a custom hook. But your idea of adding the ability to load more global sounds pretty smart. I might look into your source and come up with a PR if I have some free time. The sounds will have to be probably keyed in some way as to be able to choose which one should the hook return. But back to the initial idea, don't you think, that this could be added by checking whether the sound is playing during unmount and adding an event listener on |
Is your feature request related to a problem? Please describe.
I'd like to have a audio in a component that gets played with a mouse click. This click switches the component shown - unmounts current component that has the audio. I'd like for the sound to finish playing first and after that unmount the audio.
Describe the solution you'd like
There could be additional parameter in the load function options - finishPlayingOnUnmount which would enable the user to set audio to finish playing and only after that destroy the instance of the audio.
Describe alternatives you've considered
It would be possible using globalAudioPlayer, but I have already sound playing in the background using globalAudioPlayer.
Thank you very much for your work!
The text was updated successfully, but these errors were encountered: