5

I have file online. I am trying to play it using media player using live streaming. But media player gives an error (-1,1004) I think my media player not getting correct url as it contains arabic characters so i tried encode it with Html.encode or UrlEncoder class still getting same error.

So at last i loaded that url in webview and on page loading finish i passed webpage url to 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 );// this passes url to media player and url will be played using media player

                } 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);
            };
        });

Its working fine ,also m able to play song but this is not standard one. For normal url (that don't have arabic characters )media player code working great.

Can you provide me some standard solution on it???

Ram kiran Pachigolla
  • 20,897
  • 15
  • 57
  • 78
Swapnil Deshmukh
  • 665
  • 1
  • 6
  • 23

1 Answers1

1

Based on error code (-1,1004) it seems you might get HTTP 403 Forbidden as an answer from server. Have you tried Uri.encode(String).toString() before mediaPlayer.setDataSource(String url)?

From https://stackoverflow.com/a/4571518/262462:

Don't use the URLEncoder class! Despite the name, that class actually does HTML form encoding, not URL encoding.

Community
  • 1
  • 1
Kuitsi
  • 1,675
  • 2
  • 28
  • 48
  • its working but still i am getting error (1, -2147483648). For that i crossed verified my url so Uri.encode() inserting some additional characters. – Swapnil Deshmukh Feb 27 '13 at 16:23
  • I can't find any reference to error code -2147483648. What do you get into LogCat? Maybe there is some hint what that error means. – Kuitsi Feb 27 '13 at 17:25
  • In logcat only showing MediaPlayer error(1, -2147483648). Nothing else. Even application not crashed. – Swapnil Deshmukh Feb 28 '13 at 14:32
  • There seems to be more questions in SO about that error code. I hope these helps you to the right direction: http://stackoverflow.com/q/10795388/262462 http://stackoverflow.com/q/8236095/262462 – Kuitsi Feb 28 '13 at 16:13