title: MediaPlayer setDataSource failed with status=0x80000000 for Ringtone set by filepath on 2.3.4
body: <p>Title says most of it.</p>
  
  <p>My application has been playing ringtones pointed by uri like <code>content://media/internal/audio/media/387</code> or <code>content://media/external/audio/media/1655</code> (for custom ringtones on SDcard I believe) using both <code>setDataSource(fileInfo)</code> and <code>setDataSource(mContext, Uri.parse(fileInfo))</code>.</p>
  
  <p>In each case I have received logs with information about <code>setDataSource failed.: status=0x80000000</code> exception on phones using Android 4.x (different versions).</p>
  
  <p>Seeing that the error happens only to ringtones pointed by content uri, but not to single files pointed by path, I have decided to use paths for ringtones as well which fixed problem on above phones (while still using <code>setDataSource(mContext, Uri.parse(fileInfo))</code> )</p>
  
  <p>It has however started problems on phones with Android 2.3.4-2.3.6 (not on mine 2.3.3 though):</p>
  
  <ul>
  <li>I have received few logs with exception: <code>setDataSource failed.: status=0x80000000</code> for files with paths like <code>/system/media/audio/ringtones/TwirlAway.ogg</code></li>
  <li><p>I have also received a log about <code>MediaPlayer.onErrorListener.onError(int what, int extra)</code> method call with <code>what=1</code> and <code>extra=-2147483648</code>, which, from what I know, suggest either that file is missing or it is corrupted. However I perform </p>
  
  <pre><code>File file = new File(fileInfo);
  if (!file.exists())
  </code></pre></li>
  </ul>
  
  <p>check in such situation and it returned that file does exist - is it corrupted then? Highly unlikely for music file in internal memory.</p>
  
  <p>To sum up:</p>
  
  <ul>
  <li>works with <code>setDataSource("content://media/internal/audio/media/52")</code></li>
  <li>throws exception: <code>setDataSource failed.: status=0x80000000</code> for <code>setDataSource(mContext, "/system/media/audio/ringtones/TwirlAway.ogg")</code></li>
  </ul>
  
  <p>Interestingly, first few lines of <code>setDataSource(Context context, Uri uri, Headers headers)</code> method which is called by <code>setDataSource(Context context, Uri uri)</code> are (<a href="http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.3.4_r1/android/media/MediaPlayer.java">from GrepCode source for 2.3.4</a>):</p>
  
  <pre><code> String scheme = uri.getScheme();
       if(scheme == null || scheme.equals("file")) {
           setDataSource(uri.getPath());
           return;
       }
  </code></pre>
  
  <p>So, after all, it just fails for <code>setDataSource("/system/media/audio/ringtones/TwirlAway.ogg")</code>. I have taken paths to ringtones from uris by using:</p>
  
  <pre><code>private static String getRingtonePathFromContentUri(Context context,
          Uri contentUri) {
  
      String[] proj = { MediaStore.Audio.Media.DATA };
      Cursor ringtoneCursor = context.getContentResolver().query(contentUri,
              proj, null, null, null);
      ringtoneCursor.moveToFirst();
      return ringtoneCursor.getString(ringtoneCursor
              .getColumnIndexOrThrow(MediaStore.Audio.Media.DATA));
  }
  </code></pre>
  
  <p>Any ideas what can be causing error throwing? Maybe those are some issues caused by lack of reading permissions?
  I guess source code for native setDataSource(String path) function would help a lot, but I wasn't able to find it.</p>