Friday, April 30, 2010

Best Emulator To Play Diamond

reading MP3 tags

The following is a simple guide on how Android reading tags of MP3 possible. Access to information of different data types (eg audio or video) is in Android exclusively on so-called content providers. Es existiert eine ganze Reihe von Content-Providern, wobei über eine konstante URI auf einen bestimmten Satz von Daten zugegriffen werden kann. Alle standardmäßig vorhandenen Content-Provider sind im Package android.provider zusammengefasst. Die folgende Codezeile definiert eine URI zum Content-Provider, welcher die Media-Informationen von Audiodateien auf der SD-Card bereithält:
    Die Konstante
  1. EXTERNAL_CONTENT_URI
    verweist dabei explizit auf den Pfad "/sdcard/"
    .


    Es wird nun eine Auflistung benötigt, welche sämtliche mp3-Dateiinformationen beinhaltet, which are desired by the content provider. Location as a simple array is used: String [] tags = new String [] {

  2. android.provider.

    MediaStore.Audio.Media._ID,


    android.provider. MediaStore.Audio.Media.TITLE,
    android.provider. MediaStore.Audio.Media.ARTIST,
    android.provider. MediaStore.Audio.Media.ALBUM,
    android.provider. MediaStore.Audio.Media.YEAR
    };
    At defined in step 1, content providers can now by an object of class cursor query is executed, the content provider is searched for all requirements of the array:
    cursor cursor = managed query (uri, tags, null, null, null);


  3. Using the following code then the (partial) result of the query is read and stored in a simple list:

    List \u0026lt;String>

  4. interpreters = new ArrayList
  5. ();

    cursor. MoveToFirst ( )
    ;
    do { interpreters. add
    (
    cursor
    getString ( cursor getColumnIndexOrThrow ( "ARTIST" ) ) ..) ;} while (. cursor
    MoveToNext
    (
    ) ) ; The example then saves the contents of the tag "ARTIST" of all data stored on the SD card mp3 files as strings in the list interpreters.

    --us

0 comments:

Post a Comment