-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMusic.cpp
More file actions
45 lines (36 loc) · 752 Bytes
/
Music.cpp
File metadata and controls
45 lines (36 loc) · 752 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "Music.h"
df::Music::Music(){
}
// Associate music buffer with file.
// Return 0 if ok, else -1
int df::Music::loadMusic(std::string filename){
if (music.openFromFile(filename))
return 0;
return -1;
}
// Set labl associated with music.
void df::Music::setLabel(std::string new_label){
label = new_label;
}
// Get label associated with music.
std::string df::Music::getLabel() const{
return label;
}
// Play music
// If loop is true, repeat play when done.
void df::Music::play(bool loop){
music.setLoop(loop);
music.play();
}
// Stop music.
void df::Music::stop(){
music.stop();
}
// pause music.
void df::Music::pause(){
music.pause();
}
// Return pointer to sfml music.
sf::Music *df::Music::getMusic(){
return &music;
}