为什么 SDL_Mixer 无法播放某些 mp3 的音乐?
为什么 SDL_Mixer 无法播放某些 mp3 的音乐?
我正在创建的应用程序中利用 SDL_Mixer 进行音乐播放。 对于某些歌曲(实际上是整个专辑),音乐将根本无法播放而不返回任何错误。 使用 Mix_LoadMUS 成功加载音乐数据,并且当使用该数据执行 Mix_PlayMusic 时,奇怪的是它返回 0 表示成功,但不播放音乐。 我还尝试阅读 Mix_GetError() 和 SDL_GetError() (我相信它们是相同的)以查看它是否会引发错误,但没有这样的运气。
我的问题是,SDL_mixer 无法播放特定 mp3 的其他原因是什么?
我知道 MP3 可以使用,因为我可以在其他音乐播放器中播放它们。 我还知道,由于 Mix_PlayingMusic 返回 0,他们没有在播放(而不是音量被调低)。
谢谢大家!
Why would SDL_Mixer not play music for certain mp3s?
I am utilizing SDL_Mixer for music playback in an application I am creating. On certain songs (entire albums actually), the music will simply not play without returning any errors. The music data loads successfully using Mix_LoadMUS and when executing Mix_PlayMusic with that data, it oddly enough returns 0 for success but plays no music. I have also tried reading Mix_GetError() and SDL_GetError() (I believe they're the same) to see if it raises an error, but no such luck.
My question is, what other reasons would SDL_mixer not be able to play a particular mp3?
I know the mp3's are functional since I can play them in other music players. I also know for a fact that they are not playing (as opposed to perhaps the volume being turned down) since Mix_PlayingMusic returns 0.
Thanks everyone!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这实际上是该特定计算机的声音问题。 在另一台机器上尝试相同的测试后,声音完美无缺。 只是一个快速说明,以防其他人遇到此问题。
This actually wound up being a sound issue with that particular computer. Upon trying the same tests on another machine, the sound worked flawlessly. Just a quick note in case someone else encounters this issue.
MP3 算法的不同实现容忍不同级别的格式一致性。 大多数音乐播放器的容忍度都很高,因为大多数用户宁愿听到断断续续的声音,也不愿听不到任何声音,但常见的播放库的容忍度要低得多。
我建议在音频样本编辑器中打开有问题的(或全部)mp3,例如Audacity,并且重新导出 mp3。 您可能会损失一点质量,因为 mp3 压缩本质上是有损的,但它可能会解决播放问题。
Different implementations of the MP3 algorithm tolerate different levels of conformance to the format. Most of the music players are pretty tolerant, because most users would rather hear something choppy than nothing at all, but the playback libraries that are common tolerate much less.
I'd recommend opening the offending (Or all) mp3's in an audio sample editor, such as Audacity, and reexporting the mp3. You might lose just a little bit of quality since the mp3 compression is by it's nature lossy, but it's likely to fix the playback problem.
我遇到了同样的问题,并且使用 audacity 重新导出 mp3 文件没有帮助,但是通过执行以下操作:
如果(Mix_PlayingMusic()== 0)
Mix_PlayMusic()
在事件循环中,音乐在 2 或 3 次尝试后播放(每次运行程序时都不同)。
另一个解决方案是将音乐转换为 .ogg 文件。
I had the same problem, and reexporting the mp3-files with audacity did not help, but by doing something like this:
if (Mix_PlayingMusic() == 0)
Mix_PlayMusic()
in the event loop, the music played after 2 or 3 attempts (that was different every time I ran the program).
Another solution was to convert the music to .ogg files.