[vlc-commits] commit: python-vlc: implement MediaPlayer.video_get_( size|width|height|cursor) (Jean Brouwers )

git at videolan.org git at videolan.org
Tue Nov 16 14:29:29 CET 2010


vlc/python | branch: master | Jean Brouwers <MrJean1 at Gmail.com> | Tue Nov 16 11:06:20 2010 +0100| [3c534796981b6de39e369697e0ad4e8bd9c1baab] | committer: Olivier Aubert 

python-vlc: implement MediaPlayer.video_get_(size|width|height|cursor)

Signed-off-by: Olivier Aubert <olivier.aubert at liris.cnrs.fr>

> http://git.videolan.org/gitweb.cgi/vlc/python.git/?a=commit;h=3c534796981b6de39e369697e0ad4e8bd9c1baab
---

 override.py |   48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 48 insertions(+), 0 deletions(-)

diff --git a/override.py b/override.py
index 9a62f04..4689888 100644
--- a/override.py
+++ b/override.py
@@ -155,6 +155,54 @@ class MediaPlayer:
         """
         return track_description_list(libvlc_audio_get_track_description(self))
 
+    def video_get_size(self, num=0):
+        """Get the size of a video in pixels as 2-tuple (width, height).
+
+        @param num: video number (default 0)
+        """
+        x, y = ctypes.c_ulong(), ctypes.c_ulong()  # or c_uint?
+        if libvlc_video_get_size(self, num, ctypes.byref(x), ctypes.byref(y)):
+            raise LibVLCException('invalid video number (%s)' % (num,))
+        return int(x.value), int(y.value)
+
+    def video_get_width(self, num=0):
+        """Get the width of a video in pixels.
+
+        @param num: video number (default 0)
+        """
+        return self.video_get_size(num)[0]
+
+    def video_get_height(self, num=0):
+        """Get the height of a video in pixels.
+
+        @param num: video number (default 0)
+        """
+        return self.video_get_size(num)[1]
+
+    def video_get_cursor(self, num=0):
+        """Get the mouse pointer coordinates over a video as 2-tuple (x, y).
+
+        Coordinates are expressed in terms of the decoded video resolution,
+        <b>not</b> in terms of pixels on the screen/viewport.  To get the
+        latter, you must query your windowing system directly.
+
+        Either coordinate may be negative or larger than the corresponding
+        size of the video, if the cursor is outside the rendering area.
+
+        @warning The coordinates may be out-of-date if the pointer is not
+        located on the video rendering area.  LibVLC does not track the
+        mouse pointer if it is outside the video widget.
+
+        @note LibVLC does not support multiple mouse pointers (but does
+        support multiple input devices sharing the same pointer).
+
+        @param num: video number (default 0)
+        """
+        x, y = ctypes.c_long(), ctypes.c_long()  # or c_int?
+        if libvlc_video_get_cursor(self, num, ctypes.byref(x), ctypes.byref(y)):
+            raise LibVLCException('invalid video number (%s)' % (num,))
+        return int(x.value), int(y.value)
+
 class MediaListPlayer:
     """Create a new MediaListPlayer instance.
 



More information about the vlc-commits mailing list