MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / MusicPlayer

Method MusicPlayer

source/sound/MusicPlayer.cpp:154–184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152template<> MusicPlayer* Ogre::Singleton<MusicPlayer>::msSingleton = nullptr;
153
154MusicPlayer::MusicPlayer(const std::string& musicFilesPath, Ogre::StringVectorPtr musicFilesList) :
155 mLoaded(false),
156 mCurrentTrack(std::string()),
157 mIsPlaying(false)
158{
159 OD_LOG_INF("Loading music...");
160
161 /* Create sound objects for all files, Sound objects should be deleted
162 * automatically by the sound manager.
163 */
164 for(const std::string& trackName : *musicFilesList)
165 {
166 std::unique_ptr<ODMusic> track(new ODMusic());
167 OD_LOG_INF("Loading: " + trackName);
168
169 if(track->loadFromFile(musicFilesPath + trackName))
170 {
171 mTracks.emplace(trackName, std::move(track));
172 }
173 }
174
175 if(mTracks.empty())
176 {
177 OD_LOG_INF("No music files loaded... no music will be played");
178 }
179 else
180 {
181 OD_LOG_INF("Music loading done");
182 mLoaded = true;
183 }
184}
185
186MusicPlayer::~MusicPlayer()
187{

Callers

nothing calls this directly

Calls 1

loadFromFileMethod · 0.80

Tested by

no test coverage detected