| 152 | template<> MusicPlayer* Ogre::Singleton<MusicPlayer>::msSingleton = nullptr; |
| 153 | |
| 154 | MusicPlayer::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 | |
| 186 | MusicPlayer::~MusicPlayer() |
| 187 | { |
nothing calls this directly
no test coverage detected