Skip to content

Commit

Permalink
Implement window callback methods
Browse files Browse the repository at this point in the history
  • Loading branch information
caprica committed Feb 2, 2024
1 parent fee1e56 commit a994602
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import uk.co.caprica.vlcj.binding.internal.libvlc_video_transfer_func_e;
import uk.co.caprica.vlcj.binding.internal.libvlc_video_update_output_cb;
import uk.co.caprica.vlcj.player.base.MediaPlayer;
import uk.co.caprica.vlcj.player.base.MouseButton;
import uk.co.caprica.vlcj.player.embedded.videosurface.videoengine.VideoEngine;
import uk.co.caprica.vlcj.player.embedded.videosurface.videoengine.VideoEngineCallback;
import uk.co.caprica.vlcj.player.embedded.videosurface.videoengine.VideoEngineWindowCallbackHandler;
Expand All @@ -49,6 +50,14 @@
/**
* Implementation of a video surface that bridges native video engine callbacks to a rendering API (like JOGL, LWJGL and
* so on).
* <p>
* The window callback methods <strong>must not</strong> be invoked concurrently:
* <ul>
* <li>{@link #resize(int, int)}</li>
* <li>{@link #mouseMoved(int, int)}</li>
* <li>{@link #mousePressed(MouseButton)}</li>
* <li>{@link #mouseReleased(MouseButton)}</li>
* </ul>
*/
public final class VideoEngineVideoSurface extends VideoSurface {

Expand Down Expand Up @@ -91,6 +100,44 @@ public VideoEngineVideoSurface(VideoEngine engine, VideoEngineCallback callback,
this.callback = callback;
}

/**
* Report a video surface size change to the native video surface.
*
* @param width new width
* @param height new height
*/
public void resize(int width, int height) {
windowCallbackHandler.setSize(width, height);
}

/**
* Report a mouse moved event to the native video surface
*
* @param x new mouse x position
* @param y new mouse y position
*/
public void mouseMoved(int x, int y) {
windowCallbackHandler.mouseMoved(x, y);
}

/**
* Report a mouse pressed event to the native video surface.
*
* @param mouseButton button that was pressed
*/
public void mousePressed(MouseButton mouseButton) {
windowCallbackHandler.mousePressed(mouseButton);
}

/**
* Report a mouse released event to the native video surface.
*
* @param mouseButton button that was pressed
*/
public void mouseReleased(MouseButton mouseButton) {
windowCallbackHandler.mouseReleased(mouseButton);
}

@Override
public void attach(MediaPlayer mediaPlayer) {
libvlc_video_set_output_callbacks(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

/**
* Handler component that bridges a vlcj application with the native video engine window callback.
* <p>
* The various callback method invocations <strong>must not</strong> be made concurrently.
*/
public final class VideoEngineWindowCallbackHandler implements VideoEngineWindowCallback {

Expand Down

0 comments on commit a994602

Please sign in to comment.