Error Codes Media Player syntax and definition

2019-09-11 16:25发布

问题:

I cannot find any documentation on error codes with regard to Android. I am putting together an app that seemed to be working on a lower level API setup but not on a higher one. The error occurs when trying to play an audio file and like I said it all worked in a lower version.

The error code I see is in the log are:

MediaPlayer info/warning (1, 32)
MediaPlayer Info (1,32)
MediaPlayer info/warning (1,26)
MediaPlayer Info (1,26)
MediaPlayer error(351, -4)
MediaPlayer Error(351,-4)
VideoView Error(351,-4)

So can someone please explain how this works in detail? I know I have an error in MediaPlayer and possibly VideoView as per the data above but what do the numbers represent? I assume it is a particular error but which one?

I can not seem to find anything on this and how this is decoded. Where can I find documentation on how to find out what this means that is the main question.

If I can get an answer for this particular error code even better, but again the actual documentation source so I may be able to look up additional codes myself would be of great benefit also.

Here is the exact logfile as exported by Eclipse:

07-04 12:22:48.298: V/key =(6969): http://xxxxxx/glennharrold/audio/normal/relaxsleepwellfull.mp3
07-04 12:22:48.388: D/MediaPlayer(6969): Couldn't open file on client side, trying server side   
07-04 12:22:48.388: D/SprintMM(6969): Proxy will be bypassed because of WIFI connection.
07-04 12:22:48.508: W/MediaPlayer(6969): info/warning (1, 32)
07-04 12:22:48.508: I/MediaPlayer(6969): Info (1,32)
07-04 12:22:48.508: W/MediaPlayer(6969): info/warning (1, 26)
07-04 12:22:48.508: I/MediaPlayer(6969): Info (1,26)
07-04 12:22:48.508: E/MediaPlayer(6969): error (351, -4)
07-04 12:22:48.508: E/MediaPlayer(6969): Error (351,-4)
07-04 12:22:48.508: D/VideoView(6969): Error: 351,-4

Now what is unclear is exactly what means what I can see that it may have something to do with the file not being found on the client side but this exact same code works on a lower API version I copied working code to this App to make a new one. The only thing I see in this that I did not see in my logcat in Eclipse is the (6969) and the D/, E/, W/, I/ in front of MediaPlayer text don't know what this extra stuff means and it only appears when I export the code to a text file.

回答1:

FYI, When logcat displays information it is one of the following:

  • D - D ebug
  • W - W arning
  • I - I nformation

Followed by a '/' with a identifier to identify the Java code name which is usually defined by TAG as in a standard practice of doing :

public class fooClass{
    private static final String TAG = "fooClass";
    // ... SNIP
}

Following that, is the process id of the Java code that is running in the DalvikVM, along with some informative error code/message depending on the program spec.

For example, continuing on from the Java class fooClass as highlighted above, suppose it has a function fooMethod like this:

private void fooMethod(){    
    Log.d(TAG, "fooMethod() - This is a debug message");    
    //    
    Log.i(TAG, "fooMethod() - This is a info message");    
    //    
    Log.w(TAG, "fooMethod() - This is a warning message"); 
}

Now that will show up in the log like this:

07-04 20:58:00 D/fooClass (1234): fooMethod() - This is a debug message 
07-04 20:58:00 I/fooClass (1234): fooMethod() - This is a info message 
07-04 20:58:00 W/fooClass (1234): fooMethod() - This is a warning message

Some apps, will elect to display the message at the programmer's discretion or display a cryptic message.

Notably within the Android framework itself, some services will display a meaningless message that has little significance to anyone except the developer(s) behind the ROM itself, to aid in troubleshooting.

Edit: Since the OP insisted on trying to nail down understanding this, here goes

The AOSP source code for the MediaPlayer lies on github here, look in there there's a reference to 'pvmf_return_codes.h' in the source on line number 1547, which, a quick google-fu lead to this linky. The error code and condition is as a result of incompatible or media error.