コード例 #1
0
  /**
   * Sets whether the video should be shown in fullscreen or not.
   *
   * @param value If True, the video will be shown in fullscreen. If False and {@link
   *     VideoPlayer#FullScreen()} returns True, fullscreen mode will be exited. If False and {@link
   *     VideoPlayer#FullScreen()} returns False, nothing occurs.
   */
  @SimpleProperty(userVisible = true)
  public void FullScreen(boolean value) {

    if (value && (SdkLevel.getLevel() <= SdkLevel.LEVEL_DONUT)) {
      container
          .$form()
          .dispatchErrorOccurredEvent(
              this, "FullScreen(true)", ErrorMessages.ERROR_VIDEOPLAYER_FULLSCREEN_UNSUPPORTED);
      return;
    }

    if (value != inFullScreen) {
      if (value) {
        Bundle data = new Bundle();
        data.putInt(FullScreenVideoUtil.VIDEOPLAYER_POSITION, videoView.getCurrentPosition());
        data.putBoolean(FullScreenVideoUtil.VIDEOPLAYER_PLAYING, videoView.isPlaying());
        videoView.pause();
        data.putBoolean(FullScreenVideoUtil.VIDEOPLAYER_FULLSCREEN, true);
        data.putString(FullScreenVideoUtil.VIDEOPLAYER_SOURCE, sourcePath);
        Bundle result =
            container
                .$form()
                .fullScreenVideoAction(
                    FullScreenVideoUtil.FULLSCREEN_VIDEO_ACTION_FULLSCREEN, this, data);
        if (result.getBoolean(FullScreenVideoUtil.ACTION_SUCESS)) {
          inFullScreen = true;
        } else {
          inFullScreen = false;
          container
              .$form()
              .dispatchErrorOccurredEvent(
                  this, "FullScreen", ErrorMessages.ERROR_VIDEOPLAYER_FULLSCREEN_UNAVAILBLE, "");
        }
      } else {
        Bundle values = new Bundle();
        values.putBoolean(FullScreenVideoUtil.VIDEOPLAYER_FULLSCREEN, false);
        Bundle result =
            container
                .$form()
                .fullScreenVideoAction(
                    FullScreenVideoUtil.FULLSCREEN_VIDEO_ACTION_FULLSCREEN, this, values);
        if (result.getBoolean(FullScreenVideoUtil.ACTION_SUCESS)) {
          fullScreenKilled((Bundle) result);
        } else {
          inFullScreen = true;
          container
              .$form()
              .dispatchErrorOccurredEvent(
                  this, "FullScreen", ErrorMessages.ERROR_VIDEOPLAYER_FULLSCREEN_CANT_EXIT, "");
        }
      }
    }
  }
コード例 #2
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");
      }
    }
  }
コード例 #3
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);
    }
  }