0

In my application, I am playing files from URL using MediaPlayer API.

It plays the remote file very well, the problem comes while handling errors,

1] When a file is not available on a remote URL (i.e. 404)

error message in IOExcpeiton reads, "Prepare failed.: status=0x1"

2] When the phone is not connected to internet exception message is same i.e.

"Prepare failed.: status=0x1"

How do we differentiate between 404 & no connectivity states for better handling of exceptions?

So far I have understood the IOException with the error message "Prepare failed.: status=0x1" appears only when a requested resource file or URL not available

Anubhav Gupta
  • 2,492
  • 14
  • 27
Prashant
  • 4,474
  • 8
  • 34
  • 82

1 Answers1

0

For Error : Prepare failed.: status=0x1

Ref: Android MediaPlayer throwing "Prepare failed.: status=0x1" on 2.1, works on 2.2

I do not know if this is your issue, but I just found a solution to the problem the described by Tuszy above. I could read the file I was creating from external storage but not from Cache.

The solution is that the read write permissions when writing the file are different.

Please see this excellent explanation in this blog I found.

http://blog.weston-fl.com/android-mediaplayer-prepare-throws-status0x1-error1-2147483648/

enter image description here

Ref : Internet Connection Error

getting an UnknownHostException will mean that the application was able to connect to the Internet

No it doesn't. It means the application was unable to resolve the host name. That could be because the host name doesn't exist, or because it was unable to connect to the Internet to resolve it.

When there is no Internet connection.

No specific exception. "There is no Internet connection" doesn't have a well-defined meaning. The condition resolves to one of the other failure modes below.

When the URL cannot be found.

If the host cannot be found, UnknownHostException. If the content part of the URL cannot be found, HTTP 404.

When the request timed out.

ConnectException with 'connection timed out' as the message, or SocketTimeoutException if it's a read timeout.

When the website is down.

ConnectException with 'connection refused' as the message.

When access is denied.

HTTP 403.

Ashvin solanki
  • 4,802
  • 3
  • 25
  • 65
  • @pcj sir Your Error Status=0x1 thats why i posted answer – Ashvin solanki Sep 14 '18 at 08:46
  • Dear Ashvin if you read my question carefully I know why the error coming but same error shows for two slightly different scenarios, ( 1] File not found 404 & 2] No network )What answer you have posted will be applicable if I were to play files from the local storage :) – Prashant Sep 14 '18 at 08:52
  • In your eidted answer you have provided with known Internet Error but those will be thrown if your using Volley, Media player when tested for 404 & no connectivity doesn't seem to throw these error – Prashant Sep 14 '18 at 08:54