I have a file on the Internet. I am trying to reproduce it with media player using live streaming. But the media player gives error (-1,1004) I think that my media player does not get the correct URL, because it contains Arabic characters, so I tried to encode it using Html.encode or the UrlEncoder class , still getting the same error .
So finally, I loaded this url in webview and finished loading the page. I passed the URL of the webpage to the media player.
WebView webView = new WebView(SongActivity.this);
webView.setSoundEffectsEnabled(false);
webView.loadUrl("MY URL");
webView.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
try {
playerService.startPlay(url );
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
};
public void onPageStarted(WebView view, String url,
android.graphics.Bitmap favicon) {
System.out.println("Decoding url:" + strURl);
};
});
It works great, also knows how to play a song, but it's not standard. For a normal URL (which does not have Arabic characters), the media player code works fine.
Can you provide me some standard solution?