public static Bitmap createVideoThumbnail(Context ctx, String filePath, int kind) { if (!Vitamio.isInitialized(ctx)) { return null; } Bitmap bitmap = null; MediaMetadataRetriever retriever = null; try { retriever = new MediaMetadataRetriever(ctx); retriever.setDataSource(filePath); bitmap = retriever.getFrameAtTime(-1); } catch (Exception ex) { } finally { try { retriever.release(); } catch (RuntimeException ex) { } } if (bitmap != null) { if (kind == Video.Thumbnails.MICRO_KIND) bitmap = extractThumbnail(bitmap, TARGET_SIZE_MICRO_THUMBNAIL_WIDTH, TARGET_SIZE_MICRO_THUMBNAIL_HEIGHT, OPTIONS_RECYCLE_INPUT); else if (kind == Video.Thumbnails.MINI_KIND) bitmap = extractThumbnail(bitmap, TARGET_SIZE_MINI_THUMBNAIL_WIDTH, TARGET_SIZE_MINI_THUMBNAIL_HEIGHT, OPTIONS_RECYCLE_INPUT); } return bitmap; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); io.vov.vitamio.MediaMetadataRetriever retriever = new io.vov.vitamio.MediaMetadataRetriever(this); try { path="http://gslb.miaopai.com/stream/3D~8BM-7CZqjZscVBEYr5g__.mp4"; if (path == "") { // Tell the user to provide an audio file URL. Toast.makeText(MediaMetadataRetrieverDemo.this, "Please edit MediaMetadataRetrieverDemo Activity, " + "and set the path variable to your audio file path." + " Your audio file must be stored on sdcard.", Toast.LENGTH_LONG).show(); return; } retriever.setDataSource(path); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } String duration=retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION); long durationMs = Long.parseLong(duration); String artist = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST); String title = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE); setContentView(R.layout.media_metadata); TextView textView = (TextView)findViewById(R.id.textView); textView.setText(durationMs + "" + artist + title); retriever.release(); } }
public static Bitmap createVideoThumbnail(Context ctx, String filePath, int kind) { if (!Vitamio.isInitialized(ctx)) { return null; } Bitmap bitmap = null; MediaMetadataRetriever retriever = null; try { retriever = new MediaMetadataRetriever(ctx); retriever.setDataSource(filePath); bitmap = retriever.getFrameAtTime(-1); } catch (Exception ex) { } finally { try { retriever.release(); } catch (RuntimeException ex) { } } if (bitmap != null) { if (kind == Video.Thumbnails.MICRO_KIND) bitmap = extractThumbnail(bitmap, TARGET_SIZE_MICRO_THUMBNAIL_WIDTH, TARGET_SIZE_MICRO_THUMBNAIL_HEIGHT, OPTIONS_RECYCLE_INPUT); else if (kind == Video.Thumbnails.MINI_KIND) bitmap = extractThumbnail(bitmap, TARGET_SIZE_MINI_THUMBNAIL_WIDTH, TARGET_SIZE_MINI_THUMBNAIL_HEIGHT, OPTIONS_RECYCLE_INPUT); } return bitmap; }
public static Bitmap createVideoThumbnail(Context ctx, String filePath, int kind) { if (!Vitamio.isInitialized(ctx)) { return null; } Bitmap bitmap = null; MediaMetadataRetriever retriever = null; try { retriever = new MediaMetadataRetriever(ctx); retriever.setDataSource(filePath); bitmap = retriever.getFrameAtTime(-1); } catch (Exception ex) { } finally { try { retriever.release(); } catch (RuntimeException ex) { } } if (bitmap != null) { if (kind == Video.Thumbnails.MICRO_KIND) bitmap = extractThumbnail(bitmap, TARGET_SIZE_MICRO_THUMBNAIL_WIDTH, TARGET_SIZE_MICRO_THUMBNAIL_HEIGHT, OPTIONS_RECYCLE_INPUT); else if (kind == Video.Thumbnails.MINI_KIND) bitmap = extractThumbnail(bitmap, TARGET_SIZE_MINI_THUMBNAIL_WIDTH, TARGET_SIZE_MINI_THUMBNAIL_HEIGHT, OPTIONS_RECYCLE_INPUT); } return bitmap; }
public static Bitmap createVideoThumbnail(Context ctx, String filePath, int kind) { if (!Vitamio.isInitialized(ctx)) { return null; } Bitmap bitmap = null; MediaMetadataRetriever retriever = null; try { retriever = new MediaMetadataRetriever(ctx); retriever.setDataSource(filePath); bitmap = retriever.getFrameAtTime(-1); } catch (Exception ex) { } finally { try { retriever.release(); } catch (RuntimeException ex) { } } if (bitmap != null) { if (kind == Video.Thumbnails.MICRO_KIND) bitmap = extractThumbnail(bitmap, TARGET_SIZE_MICRO_THUMBNAIL_WIDTH, TARGET_SIZE_MICRO_THUMBNAIL_HEIGHT, OPTIONS_RECYCLE_INPUT); else if (kind == Video.Thumbnails.MINI_KIND) bitmap = extractThumbnail(bitmap, TARGET_SIZE_MINI_THUMBNAIL_WIDTH, TARGET_SIZE_MINI_THUMBNAIL_HEIGHT, OPTIONS_RECYCLE_INPUT); } return bitmap; }
public static Bitmap createVideoThumbnail(Context ctx, String filePath, int kind) { if (!Vitamio.isInitialized(ctx)) { return null; } Bitmap bitmap = null; MediaMetadataRetriever retriever = null; try { retriever = new MediaMetadataRetriever(ctx); retriever.setDataSource(filePath); bitmap = retriever.getFrameAtTime(-1); } catch (Exception ex) { } finally { try { retriever.release(); } catch (RuntimeException ex) { } } if (bitmap != null) { if (kind == Video.Thumbnails.MICRO_KIND) bitmap = extractThumbnail(bitmap, TARGET_SIZE_MICRO_THUMBNAIL_WIDTH, TARGET_SIZE_MICRO_THUMBNAIL_HEIGHT, OPTIONS_RECYCLE_INPUT); else if (kind == Video.Thumbnails.MINI_KIND) bitmap = extractThumbnail(bitmap, TARGET_SIZE_MINI_THUMBNAIL_WIDTH, TARGET_SIZE_MINI_THUMBNAIL_HEIGHT, OPTIONS_RECYCLE_INPUT); } return bitmap; }
public static Bitmap createVideoThumbnail(Context ctx, String filePath, int kind) { if (!Vitamio.isInitialized(ctx)) { return null; } Bitmap bitmap = null; MediaMetadataRetriever retriever = null; try { retriever = new MediaMetadataRetriever(ctx); retriever.setDataSource(filePath); bitmap = retriever.getFrameAtTime(-1); } catch (Exception ex) { } finally { try { retriever.release(); } catch (RuntimeException ex) { } } if (bitmap != null) { if (kind == Video.Thumbnails.MICRO_KIND) bitmap = extractThumbnail(bitmap, TARGET_SIZE_MICRO_THUMBNAIL_WIDTH, TARGET_SIZE_MICRO_THUMBNAIL_HEIGHT, OPTIONS_RECYCLE_INPUT); else if (kind == Video.Thumbnails.MINI_KIND) bitmap = extractThumbnail(bitmap, TARGET_SIZE_MINI_THUMBNAIL_WIDTH, TARGET_SIZE_MINI_THUMBNAIL_HEIGHT, OPTIONS_RECYCLE_INPUT); } return bitmap; }