Using Ffmpegmediametadataretriever Github:https://github.com/wseemann/ffmpegmediametadataretriever
Delete useless library actually not much, delete MIPS and x86 folder
Code:
PrivateBitmap Getthumbnai (String path) {ffmpegmediametadataretriever fmmr=NewFfmpegmediametadataretriever (); Bitmap Bitmap=NULL; Try{fmmr.setdatasource (path); Bitmap=Fmmr.getframeattime (); if(Bitmap! =NULL) {Bitmap B2=fmmr. Getframeattime (4000000, Ffmpegmediametadataretriever.option_closest_sync); if(B2! =NULL) {Bitmap=B2; } if(Bitmap.getwidth () > 640) {//Compress if the image width specification is more than 640pxBitmap =thumbnailutils.extractthumbnail (Bitmap,640, 480, Thumbnailutils.options_recycle_input); } } } Catch(IllegalArgumentException ex) {ex.printstacktrace (); } finally{fmmr.release (); } returnbitmap; }
When it's off, get an asynchronous tune.
NewAsynctask<void, Void, bitmap>() {@OverrideprotectedBitmap doinbackground (Void ... arg0) {Bitmap b= Mainactivity. This. Getthumbnai (path); returnb; } @Overrideprotected voidOnPostExecute (Bitmap b) {if(b!=NULL) {LOG.D ("Doubi", "B!=null"); Image.setimagebitmap (b); Bar.setvisibility (View.gone); Image.setvisibility (view.visible); Play.setvisibility (view.visible); }}}.execute ();
~ ~ First record again, there is time to fine study
Android Get video thumbnail