开发者

WAV plays from file, does not play directly from URL

开发者 https://www.devze.com 2023-04-09 04:00 出处:网络
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:

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-wa开发者_StackOverflow社区v. 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.


Maybe you didn't request Internet permission in the manifest???

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号