开发者

android media player is not playing audio file from url which has space or special character

i am trying to make media player for audio file.

when i play a file which has space or special character like this

[str=**http://192.168.1.214/MusicApplication/Songs/Baek Chan & Joo Hee of 8eight.mp3**;]

using

    mediaPlayer=new MediaPlayer();
    mediaPlayer.setDataSource(str);
    mediaPlayer.prepare();

media player does not play file.

if i use this type of url:- str=**http://192.168.1.214/MusicApplication/Songs/Baek.mp3**;

it works properly. ple开发者_开发百科ase tell me what should i do to solve this type of problem.

Thank you in advance.


use the URLEncoder.encode method see this so every special character are converted into their hexadecimal value prepended by '%'. For example: '#' -> %23.

like this

mediaPlayer.setDataSource(URLEncoder.encode(str,"UTF-8"));
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜