MediaMetadataRetriever: This class is used to extract metadata from media file. It comes from “android.media.MediaMetadataRetriever” package. It has many of available metadata types. A developer can use this class as per need. Here is the below some metadata types that we can extract from a media file in android.
- METADATA_KEY_ALBUM : This key of metadata is used to extract the information about the Album associated with media file.
- METADATA_KEY_ALBUMARTIST : This key of metadata is used to extract the information about the Artist or Performer associated with media file.
- METADATA_KEY_ARTIST : This key of metadata is used to extract the information about the Artist associated with media file.
- METADATA_KEY_AUTHOR : This key of metadata is used to extract the information about the author associated with media file.
- METADATA_KEY_COMPOSER : This key of metadata is used to extract the information about the Composer associated with media file.
- METADATA_KEY_BITRATE : This key of metadata is used to extract the information about the Bitrate associated with media file.
- METADATA_KEY_GENRE: This key of metadata is used to extract the information about the Genre associated with media file.
- void setDataSource(String path) : This method is used to set the media file source path in string format.
- string extractMetadata(int keyCode) : This method is used to extract metadata as per keys selected that are mentioned above.
- byte[] getEmbeddedPicture() : This method is used to extract album art associated with media file.
Code to get Media Duration :
private long getMediaDuration(){ android.media.MediaMetadataRetriever metaRetriever = new android.media.MediaMetadataRetriever(); metaRetriever.setDataSource(mRecordedFileName); return Long.parseLong(metaRetriever.extractMetadata(android.media.MediaMetadataRetriever.METADATA_KEY_DURATION)); }
No comments:
Post a Comment