【问题标题】:WAV plays from file, does not play directly from URLWAV 从文件播放,不直接从 URL 播放
【发布时间】:2011-09-29 17:41:51
【问题描述】:

我有一个返回 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 返回的内容类型是音频/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。请问有什么想法吗?

编辑:它在模拟器上(现在),所以权限不是问题。

【问题讨论】:

    标签: android audio media-player wav


    【解决方案1】:

    也许您没有在清单中请求 Internet 权限???

    【讨论】:

    • 在模拟器上这不是问题。
    • 无论您是否使用模拟器,您都必须在清单文件中正确指定<uses-permission>。在你的情况下,你应该确保你已经指定了<uses-permission android:name="android.permission.INTERNET" />
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-01
    • 2017-01-31
    • 2023-03-31
    • 1970-01-01
    相关资源
    最近更新 更多