32 _music = raylib::LoadMusicStream(path.c_str());
39 raylib::UnloadMusicStream(_music);
43 return raylib::IsMusicValid(_music);
51 if (_state == PLAYING)
54 raylib::ResumeMusicStream(_music);
56 raylib::PlayMusicStream(_music);
61 if (_state != PLAYING)
63 raylib::PauseMusicStream(_music);
68 if (_state == STOPPED)
70 raylib::StopMusicStream(_music);
75 raylib::UpdateMusicStream(_music);
79 if (!_loop && _state == PLAYING &&
80 raylib::GetMusicTimePlayed(_music) >= raylib::GetMusicTimeLength(_music)) {
87 raylib::SetMusicVolume(_music, volume);
105 raylib::SeekMusicStream(_music, clampTime(position));
109 return raylib::GetMusicTimePlayed(_music);
113 return raylib::GetMusicTimeLength(_music);
119 _position = position;
126 _velocity = velocity;
133 float clampTime(
float position)
const {
136 if (position < 0.f)
return 0.f;
137 return (position > length) ? length : position;
140 enum State { STOPPED, PLAYING, PAUSED };
142 raylib::Music _music;
void pause() override
Suspends playback without touching the position.
Definition RayMusic.hpp:60
float getTime() const override
Get the current time of the music in seconds.
Definition RayMusic.hpp:108
Vector3f getVelocity() const override
get the velocity of the music
Definition RayMusic.hpp:128
void setLoop(bool loop) override
set the music to loop or not
Definition RayMusic.hpp:94
void stop() override
Stops playback AND rewinds to zero.
Definition RayMusic.hpp:67
bool isReady() const override
Definition RayMusic.hpp:42
void setVelocity(Vector3f velocity) override
set the velocity of the music, used by backends that apply a doppler effect
Definition RayMusic.hpp:125
void play() override
Starts playback.
Definition RayMusic.hpp:50
void setTime(float position) override
Set the time of the music in seconds.
Definition RayMusic.hpp:102
void update() override
Must be called every frame.
Definition RayMusic.hpp:74
float getVolume() const override
get the volume of the music
Definition RayMusic.hpp:90
void setPosition(Vector3f position) override
set the 3D position of the music, for backends that spatialize against a listener....
Definition RayMusic.hpp:118
void setVolume(float volume) override
set the volume of the music
Definition RayMusic.hpp:85
RayMusic(std::string path)
Definition RayMusic.hpp:31
float getLength() const override
Get the Length of the music.
Definition RayMusic.hpp:112
bool getLoop() const override
get if the music is looping or not
Definition RayMusic.hpp:98
~RayMusic() override
Definition RayMusic.hpp:38
Vector3f getPosition() const override
get the 3D position of the music
Definition RayMusic.hpp:121
Vector3< double > Vector3f
Definition Vector3.hpp:121