Example usage for android.media MediaMetadataRetriever METADATA_KEY_MIMETYPE

List of usage examples for android.media MediaMetadataRetriever METADATA_KEY_MIMETYPE

Introduction

In this page you can find the example usage for android.media MediaMetadataRetriever METADATA_KEY_MIMETYPE.

Prototype

int METADATA_KEY_MIMETYPE

To view the source code for android.media MediaMetadataRetriever METADATA_KEY_MIMETYPE.

Click Source Link

Document

The metadata key to retrieve the mime type of the data source.

Usage

From source file:com.android.camera.manager.ThumbnailViewManager.java

private String getMimeType(String filePath) {
    MediaMetadataRetriever retriever = new MediaMetadataRetriever();
    String mime = "image/jpeg";
    if (filePath != null) {
        try {/*from w  w  w  .  j  a v  a  2 s  .co m*/
            retriever.setDataSource(filePath);
            mime = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_MIMETYPE);
        } catch (IllegalStateException e) {
            return mime;
        } catch (IllegalArgumentException e) {
            return mime;
        } catch (RuntimeException e) {
            return mime;
        }
    }
    Log.d(TAG, "[getMimeType] mime = " + mime);
    return mime;
}

From source file:com.android.camera.v2.uimanager.ThumbnailManager.java

private String getMimeType(String filePath) {
    MediaMetadataRetriever retriever = new MediaMetadataRetriever();
    String mime = "image/jpeg";
    if (filePath != null) {
        try {/*from   w  w  w. j  a  v a  2s.com*/
            retriever.setDataSource(filePath);
            mime = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_MIMETYPE);
        } catch (IllegalStateException e) {
            return mime;
        } catch (IllegalArgumentException e) {
            return mime;
        } catch (RuntimeException e) {
            return mime;
        }
    }
    LogHelper.i(TAG, "[getMimeType] mime = " + mime);
    return mime;
}