Code example for MediaMetadataRetriever

Methods: getFrameAtTime, release, setDataSource

0
	public Bitmap createVideoThumbnail(String path , long position) {
		System.out.println("CREATE THUM£££££");
		System.out.println("MEDIA RETRIEVER "+path);
        System.out.println("POSITION "+position);
	    Bitmap bitmap = null;
	    MediaMetadataRetriever retriever = new MediaMetadataRetriever();
	    try { 
	         System.out.println("MEDIA RETRIEVER "+path);
	         System.out.println("POSITION "+position);
	        retriever.setDataSource(path);
	        bitmap = retriever.getFrameAtTime(position,MediaMetadataRetriever.OPTION_CLOSEST_SYNC);
	        System.out.println("PRINT BITMAP "+bitmap);
	    }catch(IllegalArgumentException e){
	    	e.printStackTrace();
	    } 
	    catch (RuntimeException ex) {
	        // Assume this is a corrupt video file. 
	    }catch (Exception e) {
			// TODO: handle exception 
		} finally { 
	        try { 
	            retriever.release();
	        } catch (RuntimeException ex) {
	            // Ignore failures while cleaning up. 
	        } 
	    } 
	    return bitmap;