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;
}
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 XobotOS by xamarin.
the class VideoEditorImpl method generateProjectThumbnail.
/*
* Generate the project thumbnail
*/
private void generateProjectThumbnail() {
/*
* If a thumbnail already exists, then delete it first
*/
if ((new File(mProjectPath + "/" + THUMBNAIL_FILENAME)).exists()) {
(new File(mProjectPath + "/" + THUMBNAIL_FILENAME)).delete();
}
/*
* Generate a new thumbnail for the project from first media Item
*/
if (mMediaItems.size() > 0) {
MediaItem mI = mMediaItems.get(0);
/*
* Keep aspect ratio of the image
*/
int height = 480;
int width = mI.getWidth() * height / mI.getHeight();
Bitmap projectBitmap = null;
String filename = mI.getFilename();
if (mI instanceof MediaVideoItem) {
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
retriever.setDataSource(filename);
Bitmap bitmap = retriever.getFrameAtTime();
retriever.release();
retriever = null;
if (bitmap == null) {
String msg = "Thumbnail extraction from " + filename + " failed";
throw new IllegalArgumentException(msg);
}
// Resize the thumbnail to the target size
projectBitmap = Bitmap.createScaledBitmap(bitmap, width, height, true);
} else {
try {
projectBitmap = mI.getThumbnail(width, height, 500);
} catch (IllegalArgumentException e) {
String msg = "Project thumbnail extraction from " + filename + " failed";
throw new IllegalArgumentException(msg);
} catch (IOException e) {
String msg = "IO Error creating project thumbnail";
throw new IllegalArgumentException(msg);
}
}
try {
FileOutputStream stream = new FileOutputStream(mProjectPath + "/" + THUMBNAIL_FILENAME);
projectBitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
stream.flush();
stream.close();
} catch (IOException e) {
throw new IllegalArgumentException("Error creating project thumbnail");
} finally {
projectBitmap.recycle();
}
}
}
use of android.media.MediaMetadataRetriever in project JamsMusicPlayer by psaravan.
the class AsyncPlayFolderRecursiveTask method extractFileMetadata.
//Extracts specific ID3 metadata from an audio file and returns them in an ArrayList.
public static ArrayList<Object> extractFileMetadata(String filePath) {
ArrayList<Object> metadata = new ArrayList<Object>();
MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
mediaMetadataRetriever.setDataSource(filePath);
metadata.add(mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE));
metadata.add(mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST));
metadata.add(mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ALBUM));
metadata.add(mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION));
metadata.add(mediaMetadataRetriever.getEmbeddedPicture());
return metadata;
}
Aggregations