| 147 | } |
| 148 | |
| 149 | float SoundManager::getSoundFileDuration(const std::string& vfsPath) |
| 150 | { |
| 151 | auto file = openSoundFile(vfsPath); |
| 152 | |
| 153 | if (!file) |
| 154 | { |
| 155 | throw std::out_of_range("Could not resolve sound file " + vfsPath); |
| 156 | } |
| 157 | |
| 158 | auto extension = string::to_lower_copy(os::getExtension(file->getName())); |
| 159 | |
| 160 | try |
| 161 | { |
| 162 | if (extension == "wav") |
| 163 | { |
| 164 | return WavFileLoader::GetDuration(file->getInputStream()); |
| 165 | } |
| 166 | else if (extension == "ogg") |
| 167 | { |
| 168 | return OggFileLoader::GetDuration(*file); |
| 169 | } |
| 170 | } |
| 171 | catch (const std::runtime_error& ex) |
| 172 | { |
| 173 | rError() << "Error determining sound file duration " << ex.what() << std::endl; |
| 174 | } |
| 175 | |
| 176 | return 0.0f; |
| 177 | } |
| 178 | |
| 179 | void SoundManager::reloadSounds() |
| 180 | { |
no test coverage detected