예제 #1
0
  private void showPreview(int position) {
    if (mMediaInfo.getUri() == null || mMediaInfo.getUri().getString().isEmpty()) {
      return;
    }

    int seekTo = percentToPosition(position);

    mVideoPosition = seekTo / 1000;

    mVideoView.seekTo((int) mVideoPosition);
  }
예제 #2
0
  public void enableSegmentPicker(boolean enable) {
    mEnableSegmentPicker = enable;

    int visibility = enable ? View.VISIBLE : View.INVISIBLE;

    if (mMediaInfo.getUri() != null) {
      mSegmentSelector.setVisibility(visibility);
    }
  }
예제 #3
0
  public void setMediaUri(com.intel.inde.mp.Uri uri) {
    int visibility = (uri == null) ? View.INVISIBLE : View.VISIBLE;

    if (mEnableSegmentPicker) {
      mSegmentSelector.setVisibility(visibility);
    }

    mDeleteButton.setVisibility(visibility);
    mTitleText.setVisibility(visibility);
    mDurationText.setVisibility(visibility);
    mVideoView.setVisibility(visibility);

    if (uri == null) {
      mediaFileName = null;

      mVideoDuration = 0;
      mVideoPosition = 0;

      postInvalidate();

      return;
    }

    try {
      mMediaInfo.setUri(uri);
    } catch (Exception ex) {
      throw new IllegalArgumentException("Unsupported media file format");
    }

    mVideoDuration = mMediaInfo.getDurationInMicroSec();
    mVideoPosition = (mVideoDuration / 2);

    mVideoView.setVideoURI(Uri.parse(uri.getString()));

    String duration = Format.duration(mVideoDuration / 1000);

    mTitleText.setText(mediaFileName);
    mDurationText.setText(duration);

    mSegmentSelector.setStartPosition(0);
    mSegmentSelector.setEndPosition(100);

    showPreview(10);
  }
  protected void getFileInfo() {
    try {
      mediaFileInfo = new MediaFileInfo(new AndroidMediaObjectFactory(getApplicationContext()));
      mediaFileInfo.setUri(mediaUri1);

      duration = mediaFileInfo.getDurationInMicroSec();

      audioFormat = (AudioFormat) mediaFileInfo.getAudioFormat();
      if (audioFormat == null) {
        showMessageBox(
            "Audio format info unavailable",
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialogInterface, int i) {}
            });
      }

      videoFormat = (VideoFormat) mediaFileInfo.getVideoFormat();
      if (videoFormat == null) {
        showMessageBox(
            "Video format info unavailable",
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialogInterface, int i) {}
            });
      } else {
        videoWidthIn = videoFormat.getVideoFrameSize().width();
        videoHeightIn = videoFormat.getVideoFrameSize().height();
      }
    } catch (Exception e) {
      String message = (e.getMessage() != null) ? e.getMessage() : e.toString();

      showMessageBox(
          message,
          new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {}
          });
    }
  }
  protected void displayVideoFrame(SurfaceHolder holder) {

    if (videoFormat != null) {
      try {
        ISurfaceWrapper surface = AndroidMediaObjectFactory.Converter.convert(holder.getSurface());
        mediaFileInfo.setOutputSurface(surface);

        ByteBuffer buffer = ByteBuffer.allocate(1);
        mediaFileInfo.getFrameAtPosition(100, buffer);

      } catch (Exception e) {
        String message = (e.getMessage() != null) ? e.getMessage() : e.toString();

        showMessageBox(
            message,
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialogInterface, int i) {}
            });
      }
    }
  }
예제 #6
0
 public void updateView() {
   if (mVideoView != null && mMediaInfo.getUri() != null) {
     int position = (int) mVideoPosition;
     mVideoView.seekTo(position);
   }
 }
예제 #7
0
 public com.intel.inde.mp.Uri getUri() {
   return mMediaInfo.getUri();
 }