|
| | SfmlMusic (std::string path) |
| | ~SfmlMusic () override=default |
| bool | isReady () const override |
| void | play () override |
| | Starts playback.
|
| void | pause () override |
| | Suspends playback without touching the position.
|
| void | stop () override |
| | Stops playback AND rewinds to zero.
|
| void | update () override |
| | Must be called every frame.
|
| void | setVolume (float volume) override |
| | set the volume of the music
|
| float | getVolume () const override |
| | get the volume of the music
|
| void | setLoop (bool loop) override |
| | set the music to loop or not
|
| bool | getLoop () const override |
| | get if the music is looping or not
|
| void | setTime (float position) override |
| | Set the time of the music in seconds.
|
| float | getTime () const override |
| | Get the current time of the music in seconds.
|
| float | getLength () const override |
| | Get the Length of the music.
|
| void | setPosition (Vector3f position) override |
| | set the 3D position of the music, for backends that spatialize against a listener. A backend without real spatial audio may just store this and keep playing at full volume - a no-op here still leaves usable music, unlike a fake 3D model with nothing to render.
|
| Vector3f | getPosition () const override |
| | get the 3D position of the music
|
| void | setVelocity (Vector3f velocity) override |
| | set the velocity of the music, used by backends that apply a doppler effect
|
| Vector3f | getVelocity () const override |
| | get the velocity of the music
|
| virtual | ~IMusic ()=default |
sfml music stream.
sf::Music already carries the three states (stopped/playing/paused), so play()/pause()/stop() just guard on getStatus() - raylib, by contrast, had to track an enum by hand. setTime() clamps the position, sfml falling back to zero past the end.
Starts playback.
Three states, and every action does ONLY what it says :
stopped --play()--> playing --pause()--> paused
paused --play()--> playing (resumes where it was)
stopped --play()--> playing (from zero)
play() on a stream that is already playing DOES NOTHING. It does not restart from the beginning : without that rule, a play() called every frame stutters on one vendor and plays normally on the other. To restart, call stop() then play(), or setTime(0) - explicitly.
Implements audio::IMusic.
| void SfmlMusic::update |
( |
| ) |
|
|
inlineoverridevirtual |
Must be called every frame.
On a backend that refills its buffer in a thread this is a no-op - the call stays mandatory and always valid, otherwise game code would have to know which vendor is behind it.
This is also where a non-looping stream that reaches its end moves itself into the state of a stop().
Implements audio::IMusic.