Ejemplo n.º 1
0
  private void deleteAllCacheFile() {
    for (OperateNote note : operateNotesList) {
      if (note.videoPath != null && !note.videoPath.equals(videoPath)) {
        ZFileSystem.delFile(note.videoPath);
      }
    }

    for (String path : originalPathList) {
      if (path != null && !path.equals(diaryEditNote.mediaPath)) {
        ZFileSystem.delFile(path);
      }
    }
  }
Ejemplo n.º 2
0
  private void processUndo() {
    if (operateNotesList.size() < 1) {
      ivUndo.setEnabled(false);
      return;
    }

    OperateNote operate = operateNotesList.removeLast();

    OperateNote secondLastOperate = null;
    if (operateNotesList.size() > 0) {
      secondLastOperate = operateNotesList.getLast();
    } else {
      ivUndo.setEnabled(false);
    }

    switch (operate.operateType) {
      case OPERATE_CLIP:
        if (secondLastOperate != null) {
          curVideoPath = secondLastOperate.videoPath;
          curVideoDuration = new Mp4InfoUtils(curVideoPath).totaltime;
          reloadVideo();
        } else {
          curVideoPath = videoPath;
          curVideoDuration = new Mp4InfoUtils(curVideoPath).totaltime;
          reloadVideo();
        }
        processOriginalUndo();
        break;
      case OPERATE_COVER:
        if (isCoverSetted()) {
          revocateVideoCover(secondLastOperate.coverTime);
        } else {
          flCoverSetted.setVisibility(View.GONE);
          ivCover.setVisibility(View.VISIBLE);
          ivCoverSetted.setImageBitmap(null);
          thumbBmp = null;
          videoCoverTime = 0;
        }
        break;
      case OPERATE_ROTATE:
        revocateRotate();
        break;
    }

    if (operate.videoPath != null
        && !operate.videoPath.equals(videoPath)
        && !operate.videoPath.equals(curVideoPath)) {
      ZFileSystem.delFile(operate.videoPath);
    }
  }
Ejemplo n.º 3
0
  private void processOriginalUndo() {
    if (videoPath.equals(diaryEditNote.mediaPath)) {
      return;
    }
    String originalPath = originalPathList.removeLast();

    String path = "";
    if (originalPathList.size() < 1) {
      path = diaryEditNote.mediaPath;
    } else {
      path = originalPathList.getLast();
    }
    curOriginalVideoPath = path;
    if (!originalPath.equals(curOriginalVideoPath)
        && originalPath.equals(diaryEditNote.mediaPath)) {
      ZFileSystem.delFile(originalPath);
    }
  }
Ejemplo n.º 4
0
 private void montageOriginalVideo(String inputFile, boolean isSelectedDelete) {
   if (videoPath.equals(diaryEditNote.mediaPath)) {
     return;
   }
   XMp4Box mMp4Box = new XMp4Box();
   String videoID = DiaryController.getNextUUID();
   String RECORD_FILE_DIR =
       Constant.SD_STORAGE_ROOT + "/" + ActiveAccount.getInstance(this).getLookLookID() + "/video";
   String outputFile =
       Environment.getExternalStorageDirectory() + RECORD_FILE_DIR + "/" + videoID + ".mp4";
   if (isSelectedDelete) {
     String outputFile1 =
         Environment.getExternalStorageDirectory()
             + RECORD_FILE_DIR
             + "/"
             + videoID
             + "_temp1.mp4";
     int ret1 = mMp4Box.splitFile(inputFile, outputFile1, 0, (float) startMontageTime);
     String outputFile2 =
         Environment.getExternalStorageDirectory()
             + RECORD_FILE_DIR
             + "/"
             + videoID
             + "_temp2.mp4";
     int ret2 =
         mMp4Box.splitFile(inputFile, outputFile2, (float) endMontageTime, (float) videoDuration);
     Log.d(
         TAG,
         "ret1 = "
             + ret1
             + " ret2 = "
             + ret2
             + " startTime = "
             + startMontageTime
             + " endTime = "
             + endMontageTime
             + " duration = "
             + videoDuration);
     Log.d(
         TAG,
         "len1 = "
             + (new Mp4InfoUtils(outputFile1).totaltime)
             + " len2 = "
             + (new Mp4InfoUtils(outputFile2).totaltime));
     mMp4Box.appendOpen(outputFile);
     if (ret1 == 0) {
       mMp4Box.appendFile(outputFile1);
       ZFileSystem.delFile(outputFile1);
     }
     if (ret2 == 0) {
       mMp4Box.appendFile(outputFile2);
       ZFileSystem.delFile(outputFile2);
     }
     mMp4Box.appendClose();
   } else {
     int ret =
         mMp4Box.splitFile(
             inputFile, outputFile, (float) startMontageTime, (float) endMontageTime); // 1s
     Log.d(
         TAG,
         "ret = "
             + ret
             + " startMontageTime = "
             + startMontageTime
             + " endMontageTime = "
             + endMontageTime);
   }
   originalPathList.add(outputFile);
   curOriginalVideoPath = outputFile;
 }
Ejemplo n.º 5
0
  private void montageVideo(String inputFile, boolean isSelectedDelete) {
    XMp4Box mMp4Box = new XMp4Box();
    String videoID = DiaryController.getNextUUID();
    String RECORD_FILE_DIR =
        Constant.SD_STORAGE_ROOT + "/" + ActiveAccount.getInstance(this).getLookLookID() + "/video";
    String outputFile =
        Environment.getExternalStorageDirectory() + RECORD_FILE_DIR + "/" + videoID + ".mp4";
    if (isSelectedDelete) {
      String outputFile1 =
          Environment.getExternalStorageDirectory()
              + RECORD_FILE_DIR
              + "/"
              + videoID
              + "_temp1.mp4";
      int ret1 = mMp4Box.splitFile(inputFile, outputFile1, 0, (float) startMontageTime);
      String outputFile2 =
          Environment.getExternalStorageDirectory()
              + RECORD_FILE_DIR
              + "/"
              + videoID
              + "_temp2.mp4";
      int ret2 =
          mMp4Box.splitFile(inputFile, outputFile2, (float) endMontageTime, (float) videoDuration);
      Log.d(
          TAG,
          "ret1 = "
              + ret1
              + " ret2 = "
              + ret2
              + " startTime = "
              + startMontageTime
              + " endTime = "
              + endMontageTime
              + " duration = "
              + videoDuration);
      Log.d(
          TAG,
          "len1 = "
              + (new Mp4InfoUtils(outputFile1).totaltime)
              + " len2 = "
              + (new Mp4InfoUtils(outputFile2).totaltime));
      mMp4Box.appendOpen(outputFile);
      if (ret1 == 0) {
        mMp4Box.appendFile(outputFile1);
        ZFileSystem.delFile(outputFile1);
      }
      if (ret2 == 0) {
        mMp4Box.appendFile(outputFile2);
        ZFileSystem.delFile(outputFile2);
      }
      mMp4Box.appendClose();
    } else {
      int ret =
          mMp4Box.splitFile(
              inputFile, outputFile, (float) startMontageTime, (float) endMontageTime); // 1s
      Log.d(
          TAG,
          "ret = "
              + ret
              + " startMontageTime = "
              + startMontageTime
              + " endMontageTime = "
              + endMontageTime);
    }

    if (isVideoRolated()) {
      mMediaPlayer.saveOrientation(outputFile);
    }

    ivDone.setEnabled(true);
    ivUndo.setEnabled(true);
    OperateNote operate = new OperateNote();
    operate.operateType = OPERATE_CLIP;
    operate.videoPath = outputFile;
    operate.angle = curAngle;
    operate.coverTime = videoCoverTime;
    curVideoPath = outputFile;
    curVideoDuration = new Mp4InfoUtils(curVideoPath).totaltime;
    Log.d(
        TAG,
        "curVideoPath = "
            + curVideoPath
            + " curVideoDuration = "
            + curVideoDuration
            + " inputFile = "
            + inputFile);
    operateNotesList.add(operate);

    reloadVideo();
  }