Example #1
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");
      }
    }
  }
Example #2
0
  private void prepareToDie() {
    if (videoView.isPlaying()) {
      videoView.stopPlayback();
    }
    videoView.setVideoURI(null);
    videoView.clearAnimation();

    delayedStart = false;
    mediaReady = false;

    if (inFullScreen) {
      Bundle data = new Bundle();
      data.putBoolean(FullScreenVideoUtil.VIDEOPLAYER_FULLSCREEN, false);
      container
          .$form()
          .fullScreenVideoAction(
              FullScreenVideoUtil.FULLSCREEN_VIDEO_ACTION_FULLSCREEN, this, data);
    }
  }