Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I noticed the same issue on ICS (On Galaxy SII and Galaxy Tab II both running ICS 4.0.3). This seems to impact only mp3.</p> <p>I guess one of the solutions as William suggested would be to use an external library but I also prefer to use what android offers rather then external libraries.</p> <p>What bothers me is that I cannot find other posts reporting the same issue apart from this one. Though, I don't think I am doing it wrong:</p> <p>I have tried two solutions:</p> <pre><code>MediaMetadataRetriever mmdr = new MediaMetadataRetriever(); mmdr.setDataSource(path); String title = mmdr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE); </code></pre> <p>and</p> <pre><code>File file = new File(path); FileInputStream inputStream; inputStream = new FileInputStream(file); mmdr = new MediaMetadataRetriever(); mmdr.setDataSource(inputStream.getFD()); inputStream.close(); String title = mmdr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE); </code></pre> <p>MediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE) always retuns null.</p> <p>The path is correct and the mp3 file does have the ID3 tag with the title and everything.</p> <p>A solution that I thought of apart from using an external library would be to query the MediaStore on the file's path:</p> <pre><code>Cursor c = mContext.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, new String[] {MediaStore.MediaColumns.TITLE}, MediaStore.MediaColumns.DATA + "=?", new String[] { path }, null); String title; if(c!=null &amp;&amp; c.moveToFirst()) title = c.getString(c.getColumnIndex(MediaStore.MediaColumns.TITLE)) } </code></pre> <p>If the MediaScanner scanned it (it should have), the info should be there. This should also work for API levels before 10.</p> <p>Basically, what I do in my project is the following: If SDK version is &lt; 10 or the file's extension is mp3 and SDK version is 15, I query the MediaStore, otherwise I use MediaMetaDataRetriever.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload