Code example for MediaMetadataRetriever

Methods: getFrameAtTimereleasesetDataSource

0
            return android.media.ThumbnailUtils.createVideoThumbnail(filePath, kind);
        } 
         
        // MediaMetadataRetriever is not available for Android version less than 10 
        // but we need to use it in order to get first frame of the video for thumbnail. 
        MediaMetadataRetriever retriever = new MediaMetadataRetriever();
         
        try { 
            retriever.setDataSource(filePath);
            bitmap = retriever.getFrameAtTime(0);
        } catch (IllegalArgumentException ex) {
            // Assume this is a corrupt video file 
        } catch (RuntimeException ex) {
            // Assume this is a corrupt video file. 
        } finally { 
            try { 
                retriever.release();
            } catch (RuntimeException ex) {
                // Ignore failures while cleaning up. 
                Log.w("ThumbnailUtils", "MediaMetadataRetriever failed with exception: " + ex);
            } 
        } 
Contextual code suggestions in your IDE  Get Codota for Java