2016-11-26 200 views

回答

0

視頻縮略圖,服務器

final File myFile = new File(selectedPath); 
    Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(selectedPath, MediaStore.Video.Thumbnails.MINI_KIND); 
    String thumbnail = getStringImage(bitmap); 

//Server side 
    params.put("thumnails",thumbnail); 

public String getStringImage(Bitmap bmp){ 
     ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
     bmp.compress(Bitmap.CompressFormat.JPEG, 100, baos); 
     byte[] imageBytes = baos.toByteArray(); 
     String encodedImage = Base64.encodeToString(imageBytes, Base64.DEFAULT); 
     return encodedImage; 
    } 
相關問題