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);
}
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;
}
}
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;
}
}
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;
}
}
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;
}
Aggregations