Ejemplo n.º 1
0
 public void release() {
   if (!isVideo) return;
   player.stop();
   player.release();
   playerFactory.release();
   player = null;
   playerFactory = null;
 }
Ejemplo n.º 2
0
 /**
  * Construct a media player component.
  *
  * @param bufferFormatCallback callback used to set video buffer characteristics
  */
 public DirectMediaPlayerComponent(BufferFormatCallback bufferFormatCallback) {
   // Create the native resources
   mediaPlayerFactory = onGetMediaPlayerFactory();
   mediaPlayer =
       mediaPlayerFactory.newDirectMediaPlayer(bufferFormatCallback, onGetRenderCallback());
   // Register listeners
   mediaPlayer.addMediaPlayerEventListener(this);
   // Sub-class initialisation
   onAfterConstruct();
 }
Ejemplo n.º 3
0
 public void initVideo() {
   if (!isVideo) return;
   try {
     playerFactory = new MediaPlayerFactory(new String[] {"--no-video-title-show", "--noaudio"});
     player = playerFactory.newDirectMediaPlayer("RGBA", WIDTH, HEIGHT, WIDTH * DEPTH, this);
     player.prepareMedia(videoFile.getAbsolutePath());
   } catch (Throwable t) {
     isVideo = false;
     t.printStackTrace();
     Logger.global.log(Level.WARNING, "VLC failed to load :(");
   }
 }
Ejemplo n.º 4
0
 /**
  * Construct a media player component.
  *
  * @param format video format
  * @param width video width
  * @param height video height
  * @param pitch video pitch (also known as "stride")
  * @deprecated use {@link #DirectMediaPlayerComponent(BufferFormatCallback)} instead
  */
 @Deprecated
 public DirectMediaPlayerComponent(String format, int width, int height, int pitch) {
   // Create the native resources
   mediaPlayerFactory = onGetMediaPlayerFactory();
   mediaPlayer =
       mediaPlayerFactory.newDirectMediaPlayer(
           format, width, height, pitch, onGetRenderCallback());
   // Register listeners
   mediaPlayer.addMediaPlayerEventListener(this);
   // Sub-class initialisation
   onAfterConstruct();
 }
Ejemplo n.º 5
0
  @Override
  public void judgment() {
    if (isVideo && !isPlaying) {
      float w = (float) (scale_w / WIDTH);
      float h = (float) (scale_h / HEIGHT);
      sprite.setScale(w, h);
      player.play();
      isPlaying = true;
    } else {
      if (next_sprites.isEmpty()) return;
      if (times.isEmpty()) return;

      times.removeLast();
      this.sprite = next_sprites.removeLast();
      this.width = sprite.getWidth();
      this.height = sprite.getHeight();
    }
  }
Ejemplo n.º 6
0
 /**
  * Release the media player component and the associated native media player resources.
  *
  * <p>The associated media player factory will <em>not</em> be released, the client application is
  * responsible for releasing the factory at the appropriate time.
  */
 public final void release() {
   onBeforeRelease();
   mediaPlayer.release();
   onAfterRelease();
 }