MediaMetadataRetriever release - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for MediaMetadataRetriever release method.

This code example shows how to use the following methods:getFrameAtTime, release, setDataSource
        mThumbnailView.setImageBitmap(thumbnail);
    } 
 
    public static Bitmap createVideoThumbnail(Context context, Uri uri) {
        Bitmap bitmap = null;
        MediaMetadataRetriever retriever = new MediaMetadataRetriever();
        try { 
            retriever.setDataSource(context, uri);
            bitmap = retriever.getFrameAtTime(-1);
        } catch (RuntimeException ex) {
            // Assume this is a corrupt video file. 
        } finally { 
            try { 
                retriever.release();
            } catch (RuntimeException ex) {
                // Ignore failures while cleaning up. 
            } 
        } 
        return bitmap;
    } 
9
CodeRank
This code example shows how to use the following methods:getFrameAtTime, release, setDataSource
    } 
 
    private static Bitmap createVideoThumbnailBitmap(String filePath, FileDescriptor fd,
            int targetWidth) {
        Bitmap bitmap = null;
        MediaMetadataRetriever retriever = new MediaMetadataRetriever();
        try { 
            if (filePath != null) {
                retriever.setDataSource(filePath);
            } else { 
                retriever.setDataSource(fd);
            } 
            bitmap = retriever.getFrameAtTime(-1);
        } catch (IllegalArgumentException ex) {
            // Assume this is a corrupt video file 
        } catch (RuntimeException ex) {
            // Assume this is a corrupt video file. 
        } finally { 
            try { 
                retriever.release();

7
CodeRank
This code example shows how to use the following methods:extractMetadata, release, setDataSource
    protected void initMediaDuration() throws MmsException { 
        if (mUri == null) {
            throw new IllegalArgumentException("Uri may not be null.");
        } 
 
        MediaMetadataRetriever retriever = new MediaMetadataRetriever();
        int duration = 0;
        try { 
            retriever.setDataSource(mContext, mUri);
            String dur = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
            if (dur != null) {
                duration = Integer.parseInt(dur);
            } 
            mDuration = duration;
        } catch (Exception ex) {
            Log.e(TAG, "MediaMetadataRetriever failed to get duration for " + mUri.getPath(), ex);
            throw new MmsException(ex);
        } finally { 
            retriever.release();
        } 

7
CodeRank
This code example shows how to use the following methods:getFrameAtTime, release, setDataSource
package org.ffmpeg.android; 
 
import android.graphics.Bitmap; 
import android.media.MediaMetadataRetriever; 
import android.util.Log; 
 
public class MediaUtils { 
 
	public static Bitmap getVideoFrame(String videoPath,long frameTime) {
        MediaMetadataRetriever retriever = new MediaMetadataRetriever();
         
        try { 
            retriever.setDataSource(videoPath);      
            return retriever.getFrameAtTime(frameTime, MediaMetadataRetriever.OPTION_CLOSEST);
        } catch (IllegalArgumentException ex) {
            Log.w("FFMPEG.MediaUtils", "illegal argument exception");
             
        } catch (RuntimeException ex) {
        	Log.w("FFMPEG.MediaUtils", "error getting video frame");
                                } finally { 

7
CodeRank
This code example shows how to use the following methods:getFrameAtTime, release, setDataSource
        mThumbnailView.setImageBitmap(thumbnail);
    } 
 
    public static Bitmap createVideoThumbnail(Context context, Uri uri) {
        Bitmap bitmap = null;
        MediaMetadataRetriever retriever = new MediaMetadataRetriever();
        try { 
            retriever.setDataSource(context, uri);
            bitmap = retriever.getFrameAtTime(-1);
        } catch (RuntimeException ex) {
            // Assume this is a corrupt video file. 
        } finally { 
            try { 
                retriever.release();
            } catch (RuntimeException ex) {
                // Ignore failures while cleaning up. 
            } 
        } 
        return bitmap;
    } 
6
CodeRank
This code example shows how to use the following methods:getFrameAtTime, release, setDataSource
        return createVideoThumbnail(filePath, null, targetWidth);
    } 
 
    private static Bitmap createVideoThumbnail(String filePath, FileDescriptor fd, int targetWidth) {
        Bitmap bitmap = null;
        MediaMetadataRetriever retriever = new MediaMetadataRetriever();
        try { 
            if (filePath != null) {
                retriever.setDataSource(filePath);
            } else { 
                retriever.setDataSource(fd);
            } 
            bitmap = retriever.getFrameAtTime(-1);
        } catch (IllegalArgumentException ex) {
            // Assume this is a corrupt video file 
        } catch (RuntimeException ex) {
            // Assume this is a corrupt video file. 
        } finally { 
            try { 
                retriever.release();

6
CodeRank
This code example shows how to use the following methods:getFrameAtTime, release, setDataSource
			throw new RuntimeException(exception);
		} 
	} 
 
	private static Bitmap getVideoFrame(Context context, Uri uri, long time) {
		MediaMetadataRetriever retriever = new MediaMetadataRetriever();
 
		try { 
			retriever.setDataSource(context, uri);
			return retriever.getFrameAtTime(time);
		} catch (IllegalArgumentException ex) {
			ex.printStackTrace();
		} catch (RuntimeException ex) {
			ex.printStackTrace();
		} finally { 
			try { 
				retriever.release();
			} catch (RuntimeException ex) {
			} 
		} 

6
CodeRank
This code example shows how to use the following methods:extractMetadata, release, setDataSource
		    } while (cursor.moveToNext());
		} 
	} 
	 
	public static void getMediaInfo(String path, MediaBean bean){
		MediaMetadataRetriever retriever = new MediaMetadataRetriever();
		retriever.setDataSource(path);
		 
		File file=new File(path);
		if(file!=null){
			Log.i("TAG", "地址可用!");
			long length=file.length();
			bean.setSize(length/(1024*1024));
		} 
		 
		if(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE)!=null){
			bean.setTitle(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE));
		}else{ 
			String title = path.substring(path.lastIndexOf(File.separator)+1);
			bean.setTitle(title);

6
CodeRank
This code example shows how to use the following methods:extractMetadata, release, setDataSource
6
CodeRank
This code example shows how to use the following methods:release
	/** 
	 * Call {@link MediaMetadataRetriever#release()}. 
	 */ 
	public void release() 
	{ 
		mData.release();
	} 
} 
6
CodeRank

Related MediaMetadataRetriever release Questions & Answers:

release Method Overview
Call it when one is done with the object.
See Code Examples for other Android MediaMetadataRetriever Methods: