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"));
精彩评论