Skip to content

Commit

Permalink
Add method to get pointer location in video coordinates
Browse files Browse the repository at this point in the history
  • Loading branch information
caprica committed Aug 10, 2024
1 parent 7807032 commit bd5f0b3
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/main/java/uk/co/caprica/vlcj/player/base/VideoApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 <code>null</code> 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 <code>null</code> 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;
}
}
}

0 comments on commit bd5f0b3

Please sign in to comment.