public void setVideoPath(String path) {
   mediaMetadataRetriever = new MediaMetadataRetriever();
   try {
     mediaMetadataRetriever.setDataSource(path);
     String duration =
         mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
     videoLength = Long.parseLong(duration);
   } catch (Exception e) {
     FileLog.e("tmessages", e);
   }
 }
 public void destroy() {
   synchronized (sync) {
     try {
       if (mediaMetadataRetriever != null) {
         mediaMetadataRetriever.release();
         mediaMetadataRetriever = null;
       }
     } catch (Exception e) {
       FileLog.e("tmessages", e);
     }
   }
   for (Bitmap bitmap : frames) {
     if (bitmap != null) {
       bitmap.recycle();
     }
   }
   frames.clear();
   if (currentTask != null) {
     currentTask.cancel(true);
     currentTask = null;
   }
 }