tahamajs's picture
download
raw
929 Bytes
#include "../HederFiles/MusicPlayer.hpp"
MusicPlayer::MusicPlayer(string _filePath, float volume , float pitch)
: m_loop(false)
, filePath(_filePath)
{
m_sound = new sf::Sound();
m_buffer = new sf::SoundBuffer();
loadSound();
}
void MusicPlayer::loadSound() {
if (!m_buffer->loadFromFile(filePath)) {
cout << "Error loading Music" << endl;
}else {
m_sound->setBuffer(*m_buffer);
}
}
void MusicPlayer::setVolume(float volume) {
m_sound->setVolume(volume);
}
void MusicPlayer::setPitch(float pitch) {
m_sound->setPitch(pitch);
}
void MusicPlayer::setLoop(bool loop) {
m_loop = loop;
m_sound->setLoop(m_loop);
}
void MusicPlayer::play() {
m_sound->play();
}
void MusicPlayer::pause() {
m_sound->pause();
}
void MusicPlayer::stop() {
m_sound->stop();
}
bool MusicPlayer::isPlaying() const {
return m_sound->getStatus() == sf::Sound::Playing;
}

Xet Storage Details

Size:
929 Bytes
·
Xet hash:
11562612d874ff8c3801ac7be93b1ab940333035e15c1dab4eb7c35d84a5a40f

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.