In 2.0. Currently the only way to get sound ID is to remember the value returned from play(). It would be really useful to be able to get it with some method or something.
Do you have a use-case example?
The use case is that I have a playlist of tracks I want to play in sequence and each track already has its document ID in the database. So it would be great if I could associate the Howl object with that ID and then later on query by ID to control the fade-in/fade-out. Now I have to keep the state manually outside the Howl.
Howler isn't meant to maintain the state of your application within it, that would be completely outside the scope of the library. Am I missing something here?
So, but there should be an easy way to connect ID with the outside state. So one way is that I can set the ID from the outside (BTW, using global sequence number for IDs would be probably much simpler than current random IDs), or you provide a method for me to get an howler ID. Currently the only (public API) way to get it is from play method, but you cannot get it later on from having only the reference to the Howl object.
It could be possible to allow setting custom ID's for sounds, but that would have to be thought out more in a future release as this would too far out of the scope for 2.0.
Can you then just provide a method to get the Howl object ID?
What would you be getting it from? The ID is attached to a specific playback, not a file, etc.
I would just return self._sounds[0]._id. This is what all methods do if you do not specify the id.
This would be super handy
I know this thread is almost two years old and I came to here to see if there was any state management feature, but @goldfire did a great job of keeping this library pretty lean. This library provides a simple interface to play sounds in the browser. It is not a library for a player/playlist where state management is included. However, if you look at the example directory, he includes an example for a player.
After looking at the source code, it looks like we can just initialize a new instance of howl for each sound source and stick it in an array or even a map (object) and now they each have a unique ID (0..n) for arrays or n-unique keys. This would absolve you from having to pass an id into any of the methods :)
Most helpful comment
This would be super handy