Fixed Sound playing offset still using milliseconds

This commit is contained in:
Florian Rival
2015-05-03 13:26:46 +12:00
parent 6b27f15f9d
commit cb76e7869d
2 changed files with 19 additions and 13 deletions

View File

@@ -9,8 +9,9 @@
#include <string>
/**
* \brief Used to play a music
* \brief Represents a music to be played
*
* \see SoundManager
* \ingroup SoundEngine
*/
class GD_API Music
@@ -39,7 +40,7 @@ public:
void SetBuffer(const char * newbuffer, std::size_t size);
/**
* Open sound stored in buffer ( See SetBuffer ).
* Open music stored in buffer.
* \param size The buffer size.
*/
bool OpenFromMemory(std::size_t size);
@@ -99,12 +100,12 @@ public:
* \brief Change the current playing position of the music.
* \param timeOffset The new playing position, in seconds.
*/
void SetPlayingOffset(unsigned int timeOffset) { music.setPlayingOffset(sf::seconds(timeOffset)); };
void SetPlayingOffset(double timeOffset) { music.setPlayingOffset(sf::seconds(timeOffset)); };
/**
* \brief Return the current playing position of the music, in seconds.
*/
unsigned int GetPlayingOffset() const { return music.getPlayingOffset().asSeconds(); };
double GetPlayingOffset() const { return music.getPlayingOffset().asSeconds(); };
/**
* \brief Internal member functions to update music volume according to global volume.

View File

@@ -23,39 +23,42 @@ public:
virtual ~Sound();
/**
* Get Music SFML Status ( Paused, Playing, Stopped )
* \brief Get the sound status
* \return sf::Music::Paused, sf::Music::Playing or sf::Music::Stopped.
*/
inline sf::Sound::Status GetStatus() const { return sound.getStatus(); }
/**
* Change sound volume
* \brief Change the music volume.
* \param volume The new volume, between 0 and 100.
*/
void SetVolume(float volume_);
/**
* Get sound volume
* \brief Get the sound volume.
*/
inline float GetVolume() const { return volume; }
/**
* Change the pitch of the sound
* Change the pitch of the sound.
*/
void SetPitch(float newPitch) { sound.setPitch(newPitch); };
/**
* Get the pitch of the sound
* Get the pitch of the sound.
*/
float GetPitch() const { return sound.getPitch(); };
/**
* Change the current playing position of the sound.
* \param timeOffset The new playing position, in seconds.
*/
void SetPlayingOffset(unsigned int timeOffset) { sound.setPlayingOffset(sf::milliseconds(timeOffset)); };
void SetPlayingOffset(double timeOffset) { sound.setPlayingOffset(sf::seconds(timeOffset)); };
/**
* Return the current playing position of the music, in milliseconds.
* Return the current playing position of the music, in seconds.
*/
unsigned int GetPlayingOffset() const { return sound.getPlayingOffset().asMilliseconds(); };
double GetPlayingOffset() const { return sound.getPlayingOffset().asSeconds(); };
//Order is important :
sf::SoundBuffer buffer;
@@ -64,7 +67,9 @@ public:
std::string file;
/**
* Internal member functions to update music volume according to global volume.
* \brief Internal member functions to update music volume according to global volume.
*
* Called by the sound manager when the global volume is updated.
*/
void UpdateVolume();