Ejemplo n.º 1
0
  @Override
  public void onPrepared(MediaPlayer mp) {
    if (!isFinishing()) {
      if (mVideoView.getVideoWidth() == 0 || mVideoView.getVideoHeight() == 0) {
        Toast.makeText(
                ImportVideoActivity.this,
                R.string.record_camera_import_video_faild,
                Toast.LENGTH_SHORT)
            .show();
        finish();
        return;
      }

      mVideoView.start();
      mVideoView.setLooping(true);

      int duration = mMediaObject.getMaxDuration() - mMediaObject.getDuration();
      if (duration > mVideoView.getDuration()) duration = mVideoView.getDuration();
      System.out.println("mMediaObject.getMaxDuration()" + "    " + mMediaObject.getMaxDuration());
      System.out.println("mMediaObject.getDuration()" + "    " + mMediaObject.getDuration());
      System.out.println("mVideoView.getDuration()" + "    " + mVideoView.getDuration());

      mMediaPart =
          mMediaObject.buildMediaPart(
              mVideoPath, duration, MediaObject.MEDIA_PART_TYPE_IMPORT_VIDEO);
      // mMediaPart = mMediaObject.buildMediaPart(mVideoPath, mVideoView.getDuration(),
      // MediaObject.MEDIA_PART_TYPE_IMPORT_VIDEO);
      mProgressView.setData(mMediaObject);
    }
  }
Ejemplo n.º 2
0
  @Override
  protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    final int width = getMeasuredWidth(), height = getMeasuredHeight();
    int left = 0, right = 0, duration = 0;
    if (mMediaObject != null && mMediaObject.getMedaParts() != null) {

      left = right = 0;
      Iterator<MediaObject.MediaPart> iterator = mMediaObject.getMedaParts().iterator();
      boolean hasNext = iterator.hasNext();

      // final int duration = vp.getDuration();
      int maxDuration = mMaxDuration;
      boolean hasOutDuration = false;
      int currentDuration = mMediaObject.getDuration();
      hasOutDuration = currentDuration > mMaxDuration;
      if (hasOutDuration) {
        maxDuration = currentDuration;
        if (mListener != null) {
          mListener.runtime();
        }
      }

      while (hasNext) {
        MediaObject.MediaPart vp = iterator.next();
        final int partDuration = vp.getDuration();
        // Logger.e("[ProgressView]partDuration" + partDuration +
        // " maxDuration:" + maxDuration);
        left = right;
        right = left + (int) (partDuration * 1.0F / maxDuration * width);

        if (vp.remove) {
          // 回删
          canvas.drawRect(left, 0.0F, right, height, mRemovePaint);
        } else {
          // 画进度
          if (hasOutDuration) {
            // 超时拍摄
            // 前段
            right = left + (int) ((mMaxDuration - duration) * 1.0F / maxDuration * width);
            canvas.drawRect(left, 0.0F, right, height, mProgressPaint);

            // 超出的段
            left = right;
            right =
                left
                    + (int)
                        ((partDuration - (mMaxDuration - duration)) * 1.0F / maxDuration * width);
            canvas.drawRect(left, 0.0F, right, height, mOverflowPaint);
          } else {
            canvas.drawRect(left, 0.0F, right, height, mProgressPaint);
          }
        }

        hasNext = iterator.hasNext();
        if (hasNext) {
          // left = right - mVLineWidth;
          canvas.drawRect(right - mVLineWidth, 0.0F, right, height, mPausePaint);
        }

        duration += partDuration;
        // progress = vp.progress;
      }
    }

    // 画三秒
    if (duration < 3000) {
      left = (int) (3000F / mMaxDuration * width);
      canvas.drawRect(left, 0.0F, left + mVLineWidth, height, mThreePaint);
    }

    // 删
    //
    // 闪
    if (mActiveState) {
      if (right + 8 >= width) right = width - 8;
      canvas.drawRect(right, 0.0F, right + 8, getMeasuredHeight(), mActivePaint);
    }
  }