MediaPlayer error (1, -1004) aka MEDIA_ERROR_IO trying to stream music on Samsung S3

后端 未结 4 1611
無奈伤痛
無奈伤痛 2020-11-29 05:15

NOTE: I\'m not working at the company where I worked when I posted this question, therefore, even though some great answers might come in, I won\'t act

4条回答
  •  温柔的废话
    2020-11-29 06:08

    A definite solution for some getting -1004 on older Samsung phones:

    In my case, I'm using a Samsung Galaxy Pocket and had a mp3 file on our CDN, which wouldn't play, i.e.

    http://domain/path/audiofile

    When downloading the file to the phone, however, it plays in the native player. Not in my app and not in browsers, though. Turns out, the media player service needed a file extension to hint the media type and couldn't auto-detect based on file headers.

    I solved it by giving the file location an actual extension.

    http://domain/path/audiofile.mp3

    Solution

    1. Either give the file an extension where it's hosted (as above) or
    2. Programmatically, download the file manually, give it the correct extension on the sdcard and then play from sdcard as the source.

提交回复
热议问题