Ejemplo n.º 1
0
  /**
   * Constructs <code>CustomVideoPlayer</code> with the specified {@code height} and {@code width}
   * using the specified {@code playerPlugin} to playback media located at {@code mediaURL}. Media
   * playback begins automatically if {@code autoplay} is {@code true}.
   *
   * @param playerPlugin the plugin to use for playback.
   * @param mediaURL the URL of the media to playback
   * @param autoplay {@code true} to start playing automatically, {@code false} otherwise
   * @param height the height of the player
   * @param width the width of the player.
   * @throws LoadException if an error occurs while loading the media.
   * @throws PluginVersionException if the required player plugin version is not installed on the
   *     client.
   * @throws PluginNotFoundException if the player plugin is not installed on the client.
   * @throws NullPointerException if {@code height} or {@code width} is {@code null}
   * @see Plugin
   * @see QuickTimePlayer
   * @see WinMediaPlayer
   * @see FlashMediaPlayer
   */
  public CustomVideoPlayer(
      Plugin playerPlugin, String mediaURL, boolean autoplay, String height, String width)
      throws PluginNotFoundException, PluginVersionException, LoadException {
    if (height == null) {
      throw new NullPointerException("height cannot be null");
    }
    if (width == null) {
      throw new NullPointerException("width cannot be null");
    }

    engine = PlayerUtil.getPlayer(playerPlugin, mediaURL, autoplay, height, "100%");
    engine.addDebugHandler(
        new DebugHandler() {

          @Override
          public void onDebug(DebugEvent event) {
            fireEvent(event);
          }
        });
    engine.addLoadingProgressHandler(
        new LoadingProgressHandler() {

          @Override
          public void onLoadingProgress(LoadingProgressEvent event) {
            fireEvent(event);
          }
        });
    engine.addMediaInfoHandler(
        new MediaInfoHandler() {

          @Override
          public void onMediaInfoAvailable(MediaInfoEvent event) {
            fireEvent(event);
          }
        });
    engine.addPlayStateHandler(
        new PlayStateHandler() {

          @Override
          public void onPlayStateChanged(PlayStateEvent event) {
            fireEvent(event);
          }
        });
    engine.addPlayerStateHandler(
        new PlayerStateHandler() {

          @Override
          public void onPlayerStateChanged(PlayerStateEvent event) {
            switch (event.getPlayerState()) {
              case DimensionChangedOnVideo:
                onVideoDimensionChanged(engine.getOffsetWidth(), engine.getOffsetHeight());
                break;
              default:
                fireEvent(event);
            }
          }
        });

    engine.setConfigParameter(ConfigParameter.WMPUIMode, WinMediaPlayer.UIMode.NONE);
    engine.setControllerVisible(false);
    engine.showLogger(false);

    controller = new SimplePanel();
    controller.setWidth("100%");

    FlowPanel hp = new FlowPanel();
    hp.add(engine);
    hp.add(controller);

    super.initWidget(hp);
    setWidth(width);
  }
Ejemplo n.º 2
0
 @Override
 public void showLogger(boolean show) {
   engine.showLogger(show);
 }