Ejemplo n.º 1
0
  @Override
  public void seekBarChange(int curPos) {
    // TODO Auto-generated method stub
    double curTime = curPos * videoDuration / seekWidth;
    if (curTime < startMontageTime) {
      curTime = startMontageTime;
      montageView.setCurTime(curTime);
    }

    Log.d(
        TAG,
        "seekBarChange in curTime = "
            + curTime
            + " curPos = "
            + curPos
            + " seekWidth = "
            + seekWidth);
    if (mMediaPlayer != null) {
      int status = mMediaPlayer.getStatus();
      if (status == XEffectMediaPlayer.STATUS_UNKNOW
          || status == XEffectMediaPlayer.STATUS_STOP
          || status == XEffectMediaPlayer.STATUS_OPENED) {
        mMediaPlayer.play();
        mMediaPlayer.pause();
        //				ivPlay.setImageResource(R.drawable.play);
        ivPlay.setVisibility(View.VISIBLE);
      }
      mMediaPlayer.seek(curTime);
      montageView.postInvalidate();
    }
  }
Ejemplo n.º 2
0
 @Override
 public void seekBarCropUp(int thumb1Value, int thumb2Value) {
   // TODO Auto-generated method stub
   startMontageTime = calculateTime(thumb1Value);
   endMontageTime = calculateTime(thumb2Value);
   double laveLen = startMontageTime + (curVideoDuration - endMontageTime);
   if (laveLen < VideoMontageView.SHORTEST_TIME) {
     montageDelete.setEnabled(false);
   } else {
     montageDelete.setEnabled(true);
   }
   mMediaPlayer.seek(startMontageTime);
   montageView.setCurTime(startMontageTime);
   Log.d(
       TAG,
       "seekBarCropUp  thumb1Value = "
           + thumb1Value
           + " thumb2Value = "
           + thumb2Value
           + " startMontageTime = "
           + startMontageTime
           + " endMontageTime = "
           + endMontageTime
           + " laveLen = "
           + laveLen);
 }
Ejemplo n.º 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();
  }
Ejemplo n.º 4
0
 private void reloadVideo() {
   mMediaPlayer.stop();
   mMediaPlayer.open(curVideoPath);
   startMontageTime = 0;
   mMediaPlayer.seek(startMontageTime);
   endMontageTime = curVideoDuration;
   montageView.reset(curVideoDuration);
   //		if (isVideoRolated()) {
   //			mMediaPlayer.setCurrentOrientatin(curAngle);
   //		}
   curAngle = mMediaPlayer.getCurrentOrientation();
   generateThumbsCovers();
 }
Ejemplo n.º 5
0
  @Override
  public void onClick(View view) {
    // TODO Auto-generated method stub
    switch (view.getId()) {
      case R.id.fl_edit_diary_video:
      case R.id.iv_video_play:
        int status = mMediaPlayer.getStatus();
        if (status == XEffectMediaPlayer.STATUS_UNKNOW
            || status == XEffectMediaPlayer.STATUS_STOP
            || status == XEffectMediaPlayer.STATUS_OPENED) {
          if (status == XEffectMediaPlayer.STATUS_UNKNOW) {
            if (curVideoPath != null) {
              isPlayerPrepared = false;
              mMediaPlayer.open(curVideoPath);
            }
          }
          if (isPlayerPrepared) {
            mMediaPlayer.play();
            //					hidePlayBtn();
            if (startMontageTime > 0.1) {
              mMediaPlayer.seek(startMontageTime);
            }
            ivVideoCover.setVisibility(View.GONE);
          } else {
            isPlayerNeedToPlay = true;
          }
        } else if (mMediaPlayer.getStatus() == XEffectMediaPlayer.STATUS_PALYING) {
          mMediaPlayer.pause();
          //				ivPlay.setImageResource(R.drawable.play);
          ivPlay.setVisibility(View.VISIBLE);
          montageView.postInvalidate();
          //				hidePlayBtn();
        } else if (mMediaPlayer.getStatus() == XEffectMediaPlayer.STATUS_PAUSE) {
          mMediaPlayer.resume();
          ivPlay.setVisibility(View.INVISIBLE);
          //				ivPlay.setImageResource(R.drawable.zanting);
          //				hidePlayBtn();
        }
        break;
      case R.id.iv_edit_video_save:
        montageVideo(curVideoPath, false);
        montageOriginalVideo(curOriginalVideoPath, false);
        // 2014-4-8
        CmmobiClickAgentWrapper.onEvent(
            this, "keep_selection", DiaryEditPreviewActivity.isFromShootting ? "2" : "1");
        break;
      case R.id.iv_edit_video_delete:
        montageVideo(curVideoPath, true);
        montageOriginalVideo(curOriginalVideoPath, true);
        // 2014-4-8
        CmmobiClickAgentWrapper.onEvent(
            this, "cut_selection", DiaryEditPreviewActivity.isFromShootting ? "2" : "1");
        break;
      case R.id.iv_edit_diary_back:
        deleteAllCacheFile();
        finish();
        break;
      case R.id.iv_edit_diary_save:
        modifyDiary();
        break;
      case R.id.iv_edit_diary_undo:
        processUndo();
        break;
      case R.id.fl_edit_video_cover_setted:
        flCoverSetted.setVisibility(View.GONE);
        ivCover.setVisibility(View.VISIBLE);
        thumbBmp = null;
        ivCoverSetted.setImageBitmap(null);
        removeCoverOperate();
        if (operateNotesList.size() == 0) {
          ivDone.setEnabled(false);
        }
        break;
      case R.id.iv_edit_video_cover:
        setVideoCover(mMediaPlayer.getCurrentTime());
        // 2014-4-8
        CmmobiClickAgentWrapper.onEvent(
            this, "cover", DiaryEditPreviewActivity.isFromShootting ? "2" : "1");
        break;
        //		case R.id.video_view:
        //			ivPlay.setVisibility(View.VISIBLE);
        //			hidePlayBtn();
        //			break;
      case R.id.iv_edit_video_rotate:
        changeRotation();
        // 2014-4-8
        CmmobiClickAgentWrapper.onEvent(
            this, "spin", DiaryEditPreviewActivity.isFromShootting ? "2" : "1");
        curAngle = mMediaPlayer.getCurrentOrientation();
        OperateNote operate = new OperateNote();
        operate.operateType = OPERATE_ROTATE;
        operate.videoPath = curVideoPath;
        operate.angle = curAngle;
        operate.coverTime = videoCoverTime;
        operateNotesList.add(operate);

        Bitmap bmp = BitmapUtils.rotate(thumbBmp, (360 - curAngle) % 360, true);
        ivCoverSetted.setImageBitmap(bmp);

        //			if (ivVideoCover.getVisibility() == View.VISIBLE) {
        ivVideoCover.setImageBitmap(
            BitmapUtils.rotate(videoCoverBmp, (360 - curAngle) % 360, true));
        //			}
        break;
    }
  }