Skip to content
This repository has been archived by the owner on Nov 23, 2022. It is now read-only.

How to check if an audio file is being played #29

Open
varqasim opened this issue Oct 6, 2018 · 1 comment
Open

How to check if an audio file is being played #29

varqasim opened this issue Oct 6, 2018 · 1 comment

Comments

@varqasim
Copy link

varqasim commented Oct 6, 2018

In my use case, I want to make sure to stop any audio that is being played before playing the next one. So I try to use the stop method before playing the next audio file, but when running the function to do that, on first run time it will error out with Error: no audio playback to stop. How to bypass it, and write an if block before stopping to make sure an audio is being played?

@jaredpetersen
Copy link
Owner

Troubadour shouldn't be throwing an error when you call .stop(). It should be emitting an error event that you can listen to or ignore.

In your case, bypassing it just means ignoring the event that was emitted.

There isn't a function at the moment that can be used to check the status. However, it's possible that one can be written as there's a pointer to the audio process internally. If you decide that's something you need and you want to write it yourself, I'd be open to a pull request.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants