|
JNGL
Easy to use cross-platform 2D game library
|
Sound loaded from an OGG file. More...
#include <jngl/SoundFile.hpp>
Public Member Functions | |
| SoundFile (const std::string &filename, std::launch policy=std::launch::async) | |
| Load an OGG file called filename. | |
| SoundFile (const SoundFile &)=delete | |
| SoundFile & | operator= (const SoundFile &)=delete |
| SoundFile (SoundFile &&) noexcept | |
| SoundFile & | operator= (SoundFile &&) noexcept |
| void | play () |
| Play the sound once. If called twice the sound would also play twice. | |
| void | play (Channel &) |
| Play the sound once on the Channel. | |
| void | stop () |
| Stop the last started sound. | |
| void | stop (Channel &) |
| Stop the last started sound of this SoundFile started on the Channel. | |
| bool | isPlaying () |
| Whether the sound is still playing at least once. | |
| void | loop () |
| Play the sound in a loop. Can also be stopped using stop() | |
| void | loop (Channel &) |
| void | setVolume (float v) |
| Set volume in [0, ∞]. Default is 1.0f. | |
| void | load () |
| Block until the sound file has been fully decompressed and loaded. | |
| std::chrono::milliseconds | length () const |
| Returns the duration in ms. | |
| float | progress () const |
| Returns playing progress in [0, 1], can be used with length() to determine how much time has passed. | |
Sound loaded from an OGG file.
JNGL keeps a list of loaded sound files, so there's no need for you to use this class directly - you can just use jngl::play or Channel::play.
Definition at line 29 of file SoundFile.hpp.
|
explicit |
Load an OGG file called filename.
Loading can either happen on its own thread (std::launch::async) or the first time you try to play the file (std::launch::deferred).
| void stop | ( | Channel & | ) |
Stop the last started sound of this SoundFile started on the Channel.
| void load | ( | ) |
Block until the sound file has been fully decompressed and loaded.
| std::runtime_error | File not found or decoding errors |