@Override
  protected void modifyMainAttach() {
    if (isDiaryMontaged) {
      String inputFile = mainAudioPath;
      long currentTime = TimeHelper.getInstance().now();
      String voiceID = String.valueOf(currentTime);
      String RECORD_FILE_DIR =
          Constant.SD_STORAGE_ROOT
              + "/"
              + ActiveAccount.getInstance(this).getLookLookID()
              + "/audio";
      String outputFile =
          Environment.getExternalStorageDirectory()
              + RECORD_FILE_DIR
              + "/"
              + voiceID
              + "/"
              + voiceID
              + ".mp4";

      File dstFile = new File(outputFile);
      if (!dstFile.getParentFile().exists()) {
        dstFile.getParentFile().mkdirs();
      }
      editAttachPath = outputFile;
      montageAudio(voiceID, inputFile, outputFile); // 1s
    }

    if (mEffects.getEffectsCount() > 0) {
      try {

        String infilename = "";
        if (editAttachPath != null) {
          infilename = editAttachPath;
        } else {
          infilename = mainAudioPath;
        }
        Log.d(TAG, "infilename = " + infilename);
        EffectTransCodeUtil transCode =
            new EffectTransCodeUtil(
                handler, mEffects, infilename, this, EffectTransCodeUtil.MAIN_AUDIO);
        transCode.start("audio");
        threadsSignal = new CountDownLatch(1);
        threadsSignal.await();

        if (effectAudioPath != null) {
          if (editAttachPath != null) {
            EditMediaDetailActivity.delFile(editAttachPath);
          }
          editAttachPath = effectAudioPath;
        }

        Log.d(TAG, "editAttachPath = " + editAttachPath + " effectAudioPath = " + effectAudioPath);
      } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_setting_portraitshow);
    iv_photo = (ImageView) findViewById(R.id.iv_photo);
    animateFirstListener = new AnimateFirstDisplayListener();
    imageLoader = ImageLoader.getInstance();
    imageLoader.init(ImageLoaderConfiguration.createDefault(SettingPortraitShowActivity.this));
    options =
        new DisplayImageOptions.Builder()
            .showStubImage(R.drawable.moren_touxiang_1)
            .showImageForEmptyUri(R.drawable.moren_touxiang_1)
            .showImageOnFail(R.drawable.moren_touxiang_1)
            .cacheInMemory(true)
            .cacheOnDisc(true)
            .displayer(new SimpleBitmapDisplayer())
            .build();

    ll_portraitshow = (LinearLayout) findViewById(R.id.ll_portraitshow);
    ll_portraitshow.setOnClickListener(this);
    AccountInfo accountInfo = AccountInfo.getInstance(ActiveAccount.getInstance(this).getUID());
    if (this.getIntent().getExtras() != null) {
      FileInputStream fis;
      try {
        fis = new FileInputStream(this.getIntent().getExtras().getString("path"));
        Bitmap bitmap = BitmapFactory.decodeStream(fis);
        iv_photo.setImageBitmap(bitmap);
      } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    } else if (accountInfo != null) {
      imageLoader.displayImage(
          accountInfo.headimageurl,
          iv_photo,
          options,
          animateFirstListener,
          ActiveAccount.getInstance(this).getUID(),
          0);
    }
  }
Beispiel #3
0
  private void loadVideoData() {
    rlVideoContent = (RelativeLayout) findViewById(R.id.video_view);
    //		rlVideoContent.setOnClickListener(this);

    if (PluginUtils.isPluginMounted()) {
      mEffects = new XEffects();
    }

    userID = ActiveAccount.getInstance(ZApplication.getInstance()).getUID();
    String diaryString = getIntent().getStringExtra("diarystring");
    myDiary = new Gson().fromJson(diaryString, MyDiary.class);
    String diaryEditString =
        getIntent().getStringExtra(DiaryEditPreviewActivity.INTENT_ACTION_EDIT_NOTELIST);
    diaryEditNote = new Gson().fromJson(diaryEditString, DiaryEditNote.class);
    curOriginalVideoPath = diaryEditNote.mediaPath;
    //		diaryUUID = getIntent().getStringExtra("diaryuuid");
    //		myDiary = DiaryManager.getInstance().findMyDiaryByUUID(diaryUUID);
    //		String videoUrl = myDiary.getMainUrl();
    //
    //		MediaValue mediaValue = AccountInfo.getInstance(userID).mediamapping.getMedia(userID,
    // videoUrl);
    //		if (mediaValue != null) {
    //			videoPath =  Environment.getExternalStorageDirectory() + mediaValue.path;
    //		}
    videoPath = myDiary.getMainPath();
    Log.d(TAG, "videoPath = " + videoPath);
    videoDuration = new Mp4InfoUtils(videoPath).totaltime;
    curVideoDuration = videoDuration;
    curVideoPath = videoPath;

    startMontageTime = 0;
    endMontageTime = videoDuration;
    montageView.setTotalTime(videoDuration);
    montageView.setVideoMontageChangeListener(this);
    // 播放时间
    if (null == mMediaPlayer) {
      mMediaPlayer = new XMediaPlayer(this, mEffects, true);
      mMediaPlayer.setUpdateTimePeriod(0.1f);
      mMediaPlayer.setListener(new MyOnInfoListener());
      rlVideoContent.addView((View) mMediaPlayer.getXSurfaceView());
      if (videoPath != null) {
        mMediaPlayer.open(videoPath);
      }
    }
    generateThumbsCovers();
  }
 private void montageAudio(String videoID, String inputFile, String outputFile) {
   XMp4Box mMp4Box = new XMp4Box();
   if (isSelectedDelete) {
     String RECORD_FILE_DIR =
         Constant.SD_STORAGE_ROOT
             + "/"
             + ActiveAccount.getInstance(this).getLookLookID()
             + "/audio";
     String outputFile1 =
         Environment.getExternalStorageDirectory()
             + RECORD_FILE_DIR
             + "/"
             + videoID
             + "/"
             + "temp1.mp4";
     int ret1 = mMp4Box.splitFile(inputFile, outputFile1, 0, montageStartTime);
     String outputFile2 =
         Environment.getExternalStorageDirectory()
             + RECORD_FILE_DIR
             + "/"
             + videoID
             + "/"
             + "temp2.mp4";
     float videoDuration = (float) (montageFragment.totalTime);
     int ret2 = mMp4Box.splitFile(inputFile, outputFile2, montageEndTime, videoDuration);
     Log.d(TAG, "ret1 = " + ret1 + " ret2 = " + ret2);
     mMp4Box.appendOpen(outputFile);
     if (ret1 == 0) {
       mMp4Box.appendFile(outputFile1);
       EditMediaDetailActivity.delFile(outputFile1);
     }
     if (ret2 == 0) {
       mMp4Box.appendFile(outputFile2);
       EditMediaDetailActivity.delFile(outputFile2);
     }
     mMp4Box.appendClose();
   } else {
     mMp4Box.splitFile(inputFile, outputFile, montageStartTime, montageEndTime); // 1s
   }
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_diary_praise);

    diaryID = getIntent().getStringExtra("diaryID");

    userID = ActiveAccount.getInstance(ZApplication.getInstance()).getUID();
    ai = AccountInfo.getInstance(userID);
    ZDialog.show(R.layout.progressdialog, true, true, this);
    Requester2.getDiaryForwardUsers(getHandler(), diaryID, null, null);

    otherUserID = getIntent().getStringExtra(INTENT_ACTION_USERID);

    isShowAllPraise = false;
    inflater = LayoutInflater.from(this);
    findViewById(R.id.iv_back).setOnClickListener(this);
    listView = (PullToRefreshListView) findViewById(R.id.lv_activity_diary_praise);
    listView.setOnRefreshListener(this);
    dpList = new ArrayList<GsonResponse2.getDiaryForwardUsers>();

    lv = listView.getRefreshableView();
  }
  @Override
  protected void copyMainAttach() {
    // TODO Auto-generated method stub
    if (mainAudioPath == null) {
      return;
    }
    String audioID = String.valueOf(TimeHelper.getInstance().now());
    String dstFilePath =
        Environment.getExternalStorageDirectory().getPath()
            + Constant.SD_STORAGE_ROOT
            + "/"
            + ActiveAccount.getInstance(this).getLookLookID()
            + "/audio/"
            + audioID
            + "/"
            + audioID
            + ".mp4";

    long fileLength = copyFile2(mainAudioPath, dstFilePath);
    if (fileLength > 0) {
      editAttachPath = dstFilePath;
    }
  }
Beispiel #7
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;
 }
Beispiel #8
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();
  }