Returns album title associated with song - Android Media

Android examples for Media:Song

Description

Returns album title associated with song

Demo Code


//package com.java2s;

import android.media.MediaMetadataRetriever;

public class Main {
    /**/*  w w  w .j  a  v  a2s .c  o m*/
     * Returns album title associated with song
     *
     * @param filePath Path to song
     * @return Albums title, null on fail
     */
    public static String getAlbum(String filePath) {
        try {

            MediaMetadataRetriever metaRetriver = new MediaMetadataRetriever();
            metaRetriver.setDataSource(filePath);
            return metaRetriver
                    .extractMetadata(MediaMetadataRetriever.METADATA_KEY_ALBUM);
        } catch (Exception e) {
            return "N/A";
        }
    }
}

Related Tutorials