public void release() { if (!isVideo) return; player.stop(); player.release(); playerFactory.release(); player = null; playerFactory = null; }
/** * 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(); }
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 :("); } }
/** * 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(); }
@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(); } }
/** * 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(); }