2

I'm developing an android application. In this application, I have to play video from HTTP server. I am trying to use MediaPlayer class for playing this HTTP video steam. I am receiving "Unable play the video" error.

My WI-FI connection requires a proxy for internet access. how to specify these proxy settings.

Tony
  • 4,311
  • 26
  • 49
Ranjith
  • 181
  • 2
  • 9

1 Answers1

1

You can try:

Properties systemSettings=System.getProperties();

systemSettings.put("http.proxyHost", "your.proxy.host.here");
systemSettings.put("http.proxyPort", "8080"); // use actual proxy port

However, bear in mind that "Unable play the video" has many potential causes. Use adb logcat, DDMS, or the DDMS perspective in Eclipse to examine LogCat and look at the warnings or errors that MediaPlayer generates, to give you more clues. For example, your video may not be "safe for streaming".

Community
  • 1
  • 1
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • I tried using 'java.lang.System.setproperty("http.proxyHost", "")' , I got same error... i have also tried using 'android.provider.Settings.System' class to set Http Proxy.. But i got following exception: **Setting http_proxy has moved from android.provider.Settings.System to android.provider.Settings.Secure, value is unchanged....** when i used 'android.provider.Settings.Secure', i got **java.lang.SecurityException: Permission denial: writing to secure settings requires android.permission.WRITE_SECURE_SETTINGS**. I already have the required permission in my manifest file.... – Ranjith Jun 04 '11 at 19:36
  • 1
    I think it is not possible to set http proxy by non system applications [check this link](http://stackoverflow.com/questions/3385381/android-java-lang-securityexception-on-settings-secure-putstring). – Ranjith Jun 04 '11 at 19:36
  • I am able to play the video, when i used other network which does not require a proxy. so this error is related to network only. – Ranjith Jun 04 '11 at 19:38
  • I found an application which plays a streaming video...[npr-android-app](http://code.google.com/p/npr-android-app/)... In this application they are using a different approch for playing videos using proxy.. i think it is a workaround... they have implemented a server in their application, which handles the request using URLConnection... and URLConnection has proxy support... they are using this local server address, in MediaPlayer.... like http://localhost/videoid.. is this is only possible way... – Ranjith Jun 04 '11 at 19:47
  • @Ranjith: An ordinary SDK application cannot modify secure settings. The code I list above works for `HttpClient`, and I thought perhaps that `MediaPlayer` might honor it -- apparently, it does not. NPR's local proxy solution obviously works for them, and I do not have any other suggestion to make to you. – CommonsWare Jun 04 '11 at 19:52