Search in sources :

Example 21 with MediaMetadataRetriever

use of android.media.MediaMetadataRetriever in project glide by bumptech.

the class VideoBitmapDecoder method decode.

@Override
public Resource<Bitmap> decode(ParcelFileDescriptor resource, int outWidth, int outHeight, Options options) throws IOException {
    long frameTimeMicros = options.get(TARGET_FRAME);
    if (frameTimeMicros < 0 && frameTimeMicros != DEFAULT_FRAME) {
        throw new IllegalArgumentException("Requested frame must be non-negative, or DEFAULT_FRAME, given: " + frameTimeMicros);
    }
    Integer frameOption = options.get(FRAME_OPTION);
    final Bitmap result;
    MediaMetadataRetriever mediaMetadataRetriever = factory.build();
    try {
        mediaMetadataRetriever.setDataSource(resource.getFileDescriptor());
        if (frameTimeMicros == DEFAULT_FRAME) {
            result = mediaMetadataRetriever.getFrameAtTime();
        } else if (frameOption == null) {
            result = mediaMetadataRetriever.getFrameAtTime(frameTimeMicros);
        } else {
            result = mediaMetadataRetriever.getFrameAtTime(frameTimeMicros, frameOption);
        }
    } finally {
        mediaMetadataRetriever.release();
    }
    resource.close();
    return BitmapResource.obtain(result, bitmapPool);
}
Also used : Bitmap(android.graphics.Bitmap) MediaMetadataRetriever(android.media.MediaMetadataRetriever)

Example 22 with MediaMetadataRetriever

use of android.media.MediaMetadataRetriever in project MusicDNA by harjot-oberai.

the class EditLocalSongFragment method getBitmap.

public Bitmap getBitmap(String url) {
    android.media.MediaMetadataRetriever mmr = new MediaMetadataRetriever();
    mmr.setDataSource(url);
    Bitmap bitmap;
    byte[] data = mmr.getEmbeddedPicture();
    if (data != null) {
        bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
        return bitmap;
    } else {
        return null;
    }
}
Also used : Bitmap(android.graphics.Bitmap) MediaMetadataRetriever(android.media.MediaMetadataRetriever) MediaMetadataRetriever(android.media.MediaMetadataRetriever)

Example 23 with MediaMetadataRetriever

use of android.media.MediaMetadataRetriever in project MusicDNA by harjot-oberai.

the class ViewAlbumFragment method getBitmap.

public Bitmap getBitmap(String url) {
    android.media.MediaMetadataRetriever mmr = new MediaMetadataRetriever();
    mmr.setDataSource(url);
    Bitmap bitmap = null;
    byte[] data = mmr.getEmbeddedPicture();
    if (data != null) {
        bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
        return bitmap;
    } else {
        return null;
    }
}
Also used : Bitmap(android.graphics.Bitmap) MediaMetadataRetriever(android.media.MediaMetadataRetriever) MediaMetadataRetriever(android.media.MediaMetadataRetriever)

Example 24 with MediaMetadataRetriever

use of android.media.MediaMetadataRetriever in project MusicDNA by harjot-oberai.

the class LocalTrackRecyclerAdapter method getAlbumArt.

public static Bitmap getAlbumArt(String path) {
    android.media.MediaMetadataRetriever mmr = new MediaMetadataRetriever();
    mmr.setDataSource(path);
    Bitmap bitmap = null;
    byte[] data = mmr.getEmbeddedPicture();
    if (data != null) {
        bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
        return bitmap;
    } else {
        return null;
    }
}
Also used : Bitmap(android.graphics.Bitmap) MediaMetadataRetriever(android.media.MediaMetadataRetriever) MediaMetadataRetriever(android.media.MediaMetadataRetriever)

Example 25 with MediaMetadataRetriever

use of android.media.MediaMetadataRetriever in project MusicDNA by harjot-oberai.

the class CustomAdapter method getBitmap.

public Bitmap getBitmap(String url) {
    try {
        android.media.MediaMetadataRetriever mmr = new MediaMetadataRetriever();
        mmr.setDataSource(url);
        Bitmap bitmap = null;
        byte[] data = mmr.getEmbeddedPicture();
        if (data != null) {
            bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
            return bitmap;
        } else {
            return null;
        }
    } catch (Throwable ex) {
        ex.printStackTrace();
    }
    return null;
}
Also used : Bitmap(android.graphics.Bitmap) MediaMetadataRetriever(android.media.MediaMetadataRetriever) MediaMetadataRetriever(android.media.MediaMetadataRetriever)

Aggregations

MediaMetadataRetriever (android.media.MediaMetadataRetriever)105 Bitmap (android.graphics.Bitmap)40 FileOutputStream (java.io.FileOutputStream)15 IOException (java.io.IOException)15 BitmapFactory (android.graphics.BitmapFactory)7 TargetApi (android.annotation.TargetApi)5 File (java.io.File)5 ByteArrayInputStream (java.io.ByteArrayInputStream)3 Intent (android.content.Intent)2 Paint (android.graphics.Paint)2 MediaItem (android.media.videoeditor.MediaItem)2 WritableMap (com.facebook.react.bridge.WritableMap)2 FileInputStream (java.io.FileInputStream)2 FileNotFoundException (java.io.FileNotFoundException)2 InputStream (java.io.InputStream)2 SuppressLint (android.annotation.SuppressLint)1 Notification (android.app.Notification)1 PendingIntent (android.app.PendingIntent)1 ContentResolver (android.content.ContentResolver)1 Cursor (android.database.Cursor)1