예제 #1
0
  /**
   * Specifies the path of the button's image.
   *
   * <p>See {@link MediaUtil#determineMediaSource} for information about what a path can be.
   *
   * @param path the path of the button's image
   */
  @DesignerProperty(editorType = PropertyTypeConstants.PROPERTY_TYPE_ASSET, defaultValue = "")
  @SimpleProperty(
      description =
          "Specifies the path of the button's image.  "
              + "If there is both an Image and a BackgroundColor, only the Image will be "
              + "visible.")
  public void Image(String path) {
    // If it's the same as on the prior call and the prior load was successful,
    // do nothing.
    if (path.equals(imagePath) && backgroundImageDrawable != null) {
      return;
    }

    imagePath = (path == null) ? "" : path;

    // Clear the prior background image.
    backgroundImageDrawable = null;

    // Load image from file.
    if (imagePath.length() > 0) {
      try {
        backgroundImageDrawable = MediaUtil.getBitmapDrawable(container.$form(), imagePath);
      } catch (IOException ioe) {
        // TODO(user): Maybe raise Form.ErrorOccurred.
        Log.e(LOG_TAG, "Unable to load " + imagePath);
        // Fall through with a value of null for backgroundImageDrawable.
      }
    }

    // Update the appearance based on the new value of backgroundImageDrawable.
    updateAppearance();
  }
예제 #2
0
  /**
   * Specifies the path of the background image.
   *
   * <p>See {@link MediaUtil#determineMediaSource} for information about what a path can be.
   *
   * @param path the path of the background image
   */
  @DesignerProperty(editorType = DesignerProperty.PROPERTY_TYPE_ASSET, defaultValue = "")
  @SimpleProperty(
      category = PropertyCategory.APPEARANCE,
      description = "The screen background image.")
  public void BackgroundImage(String path) {
    backgroundImagePath = (path == null) ? "" : path;

    try {
      backgroundDrawable = MediaUtil.getBitmapDrawable(this, backgroundImagePath);
    } catch (IOException ioe) {
      Log.e(LOG_TAG, "Unable to load " + backgroundImagePath);
      backgroundDrawable = null;
    }

    ViewUtil.setBackgroundImage(frameLayout, backgroundDrawable);
    frameLayout.invalidate();
  }
예제 #3
0
  /**
   * Sets the video source.
   *
   * <p>See {@link MediaUtil#determineMediaSource} for information about what a path can be.
   *
   * @param path the path to the video source
   */
  @DesignerProperty(editorType = PropertyTypeConstants.PROPERTY_TYPE_ASSET, defaultValue = "")
  @SimpleProperty(
      description =
          "The \"path\" to the video.  Usually, this will be the "
              + "name of the video file, which should be added in the Designer.",
      category = PropertyCategory.BEHAVIOR)
  public void Source(String path) {
    if (inFullScreen) {
      container
          .$form()
          .fullScreenVideoAction(FullScreenVideoUtil.FULLSCREEN_VIDEO_ACTION_SOURCE, this, path);
    } else {
      sourcePath = (path == null) ? "" : path;

      // The source may change for the MediaPlayer, and
      // getVideoWidth or getVideoHeight may be called
      // creating an error in ResizableVideoView.
      videoView.invalidateMediaPlayer(true);

      // Clear the previous video.
      if (videoView.isPlaying()) {
        videoView.stopPlayback();
      }
      videoView.setVideoURI(null);
      videoView.clearAnimation();

      if (sourcePath.length() > 0) {
        Log.i("VideoPlayer", "Source path is " + sourcePath);

        try {
          mediaReady = false;
          MediaUtil.loadVideoView(videoView, container.$form(), sourcePath);
        } catch (IOException e) {
          container
              .$form()
              .dispatchErrorOccurredEvent(
                  this, "Source", ErrorMessages.ERROR_UNABLE_TO_LOAD_MEDIA, sourcePath);
          return;
        }

        Log.i("VideoPlayer", "loading video succeeded");
      }
    }
  }