Improvements in sound player
Some ideas for improvements/fixes for the sound player:
- [ ] Add a loading indicator after clicking the play button and before the sound is ready to play.
- [x] Issue with player in safari, not playing sounds from the start when having been played once, and doing weird things with the playhead position. E.g. https://freesound.org/people/kramsttop/sounds/170910/
This seems to happen on "oldish" desktop MacOS systems only. It can be fixed by calling audioElement.load() before calling audioElement.play() again once the sound has already been played, but this triggers a reload of the data (which I'm not sure if it uses cache or not). In any case, this is the best solution so far and the one we implemented. We only use it when we detect a desktop macOS system (there also seems to be no way to distinguish old macs from newer macs).
- [ ] Issue with playhead position in Safari which seems to glitch quite a lot
I tried quite hard to fix that but I don't seem to find a way to do it. The audioElement.currentTime value returned by Safari makes sudden jumps (it goes back unexpectedly) and therefore it is impossible to know where the playhead should be positioned. We'd probably need a completely different player implementation using web audio API...
- [ ] Add a volume slider when hovering the player and holding some key combination?
- [ ] While adding the volume player, we might plan for adding extra controls in the future like pitch (?)
- [ ] When a player is loaded, request information related to the particular sound and the logged user (e.g. if the user already rated the sound and which rating was given, or if the sound is bookmarked) so that we can show the user rating instead of the global rating and the bookmark button opened/closed. This means many more requests made to the server, so it should be though carefully how to design the way to get this information. Most likely it could be a single request the retrieves information for all sound players in a page (?).