I am using a network with proxy authentication that require username/password for authentication. I want to stream a music, and i know that MediaPlayer
only can stream from a direct network. Now, i want to use HttpClient
or other network classes to download the media and play it locally in download time, I know about downloading with using HttpClient
through the proxy network :
String M_url = "http://printf.ir/music/01.wma";
DefaultHttpClient request = new DefaultHttpClient();
request.getCredentialsProvider().setCredentials(
AuthScope.ANY,
new NTCredentials(proxyUser, proxyPassword,
proxyAddress, proxyDomain));
HttpHost p = new HttpHost(proxyAddress, proxyPort);
request.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,p);
URL url = new URL(M_url);
HttpGet httpGet = new HttpGet(new URI(url.getProtocol(), url.getHost(),
url.getPath(), url.getQuery(), null));
byte[] buffer = new byte[5 * 1024];
int readBytes = 0;
InputStream in = request.execute(httpGet).getEntity().getContent();
while ( (readBytes = in.read(buffer, 0, 1024)) != -1){
//buffer is completed
}
How can i link buffer bytes to MediaPlayer
object and play media successfully? Please give me a best performance solution.
Thanks for your advance :)