コード例 #1
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);
  }
コード例 #2
0
  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) {}
          });
    }
  }