Exemplo 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();
    }
  }
Exemplo n.º 2
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;
    }
  }