WAV 从文件播放,不直接从 URL 播放
我有一个返回 8 位 PCM、单声道、8 kHz WAV 声音的 URL。当我尝试通过 Android 的 MediaPlayer 类播放该 URL 时,我在 LogCat 中收到错误和以下内容:
09-29 17:36:40.710: ERROR/PlayerDriver(562): Command PLAYER_INIT completed with an error or info PVMFFailure
09-29 17:36:40.730: ERROR/MediaPlayer(25215): error (1, -1)
URL 返回的内容类型是 audio/x-wav。 I 调用prepareAsync()后发生错误:
String uri = "http://whatever";
s_Player.setDataSource(uri);
s_Player.setAudioStreamType(AudioManager.STREAM_MUSIC);
s_Player.prepareAsync();
当我将uri
替换为文件系统中存储的相同声音的文件路径时,它播放正常。在 Android 浏览器中播放 URL 即可。所以一定是我误用了 MediaPlayer。有什么想法吗?
编辑:它位于模拟器上(目前),因此权限不是问题。
I have a URL that returns a 8-bit PCM, mono, 8 kHz WAV sound. When I try to play that URL via Android's MediaPlayer class, I get an error and the following in LogCat:
09-29 17:36:40.710: ERROR/PlayerDriver(562): Command PLAYER_INIT completed with an error or info PVMFFailure
09-29 17:36:40.730: ERROR/MediaPlayer(25215): error (1, -1)
The content type that the URL returns is audio/x-wav. I The error occurs after calling prepareAsync():
String uri = "http://whatever";
s_Player.setDataSource(uri);
s_Player.setAudioStreamType(AudioManager.STREAM_MUSIC);
s_Player.prepareAsync();
When I replace uri
with a file path to the same sound stored in the filesystem, it plays fine. Playing the URL in the Android browser works. So it must be me somehow misusing MediaPlayer. Any ideas, please?
EDIT: it's on the emulator (for now), so permissions are not an issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许您没有在清单中请求互联网许可???
Maybe you didn't request Internet permission in the manifest???