| 140 | } |
| 141 | |
| 142 | fl::Mp3DecoderPtr FileSystem::openMp3(const char *path, fl::string *error_message) { |
| 143 | fl::ifstream file = openRead(path); |
| 144 | if (!file.is_open()) { |
| 145 | if (error_message) { *error_message = "Failed to open file: "; error_message->append(path); } |
| 146 | FL_WARN("Failed to open MP3 file: " << path); return fl::Mp3DecoderPtr(); |
| 147 | } |
| 148 | fl::Mp3DecoderPtr decoder = fl::Mp3::createDecoder(error_message); |
| 149 | if (!decoder->begin(file.rdbuf())) { |
| 150 | fl::string decoder_error; decoder->hasError(&decoder_error); |
| 151 | if (error_message) { *error_message = "Failed to initialize MP3 decoder: "; error_message->append(decoder_error); } |
| 152 | FL_WARN("Failed to initialize MP3 decoder for: " << path); return fl::Mp3DecoderPtr(); |
| 153 | } |
| 154 | return decoder; |
| 155 | } |
| 156 | |
| 157 | } // namespace fl |