From bd5f0b3a1e607d4d1140488bbd63cecb82d9d072 Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Sat, 10 Aug 2024 07:25:59 +0100 Subject: [PATCH] Add method to get pointer location in video coordinates --- .../co/caprica/vlcj/player/base/VideoApi.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/main/java/uk/co/caprica/vlcj/player/base/VideoApi.java b/src/main/java/uk/co/caprica/vlcj/player/base/VideoApi.java index c6bc4991b..7b7d0c945 100644 --- a/src/main/java/uk/co/caprica/vlcj/player/base/VideoApi.java +++ b/src/main/java/uk/co/caprica/vlcj/player/base/VideoApi.java @@ -24,10 +24,12 @@ import uk.co.caprica.vlcj.binding.internal.libvlc_video_viewpoint_t; import java.awt.Dimension; +import java.awt.Point; import static uk.co.caprica.vlcj.binding.lib.LibVlc.libvlc_media_player_set_video_title_display; import static uk.co.caprica.vlcj.binding.lib.LibVlc.libvlc_video_get_adjust_float; import static uk.co.caprica.vlcj.binding.lib.LibVlc.libvlc_video_get_adjust_int; +import static uk.co.caprica.vlcj.binding.lib.LibVlc.libvlc_video_get_cursor; import static uk.co.caprica.vlcj.binding.lib.LibVlc.libvlc_video_get_display_fit; import static uk.co.caprica.vlcj.binding.lib.LibVlc.libvlc_video_get_scale; import static uk.co.caprica.vlcj.binding.lib.LibVlc.libvlc_video_get_size; @@ -347,4 +349,30 @@ public Viewpoint newViewpoint() { public boolean updateViewpoint(Viewpoint viewpoint, boolean absolute) { return libvlc_video_update_viewpoint(mediaPlayerInstance, viewpoint.viewpoint(), absolute ? 1 : 0) == 0; } + + /** + * Get the pointer location, in terms of video resolution/coordinates, for the first video. + * + * @return cursor location, or null if not available + */ + public Point getCursor() { + return getCursor(0); + } + + /** + * Get the pointer location, in terms of video resolution/coordinates, for the specified video. + * + * @param videoNum video number, starting from zero + * @return cursor location, or null if not available + */ + public Point getCursor(int videoNum) { + IntByReference px = new IntByReference(); + IntByReference py = new IntByReference(); + int result = libvlc_video_get_cursor(mediaPlayerInstance, videoNum, px.getPointer(), py.getPointer()); + if (result == 0) { + return new Point(px.getValue(), py.getValue()); + } else { + return null; + } + } }