]> git.sesse.net Git - vlc/blobdiff - bindings/python-ctypes/override.py
python-ctypes: try to detect plugin path on win32 / macosx
[vlc] / bindings / python-ctypes / override.py
index 54a0b01b706748e2fa74bfd6ccc0c29ac2a30532..1a3968463d3ae140c5dcb5b065eddc8496eec24b 100644 (file)
@@ -24,6 +24,10 @@ class Instance:
         if p and isinstance(p[0], MediaControl):
             return p[0].get_instance()
         else:
+            if not p and detected_plugin_path is not None:
+                # No parameters passed. Under win32 and MacOS, specify
+                # the detected_plugin_path if present.
+                p=[ 'vlc', '--plugin-path='+ detected_plugin_path ]
             e=VLCException()
             return libvlc_new(len(p), p, e)
 
@@ -72,11 +76,86 @@ class MediaControl:
 
         if p and isinstance(p[0], Instance):
             e=MediaControlException()
-            return mediacontrol_new_from_instance(p[0])
+            return mediacontrol_new_from_instance(p[0], e)
         else:
+            if not p and detected_plugin_path is not None:
+                # No parameters passed. Under win32 and MacOS, specify
+                # the detected_plugin_path if present.
+                p=[ 'vlc', '--plugin-path='+ detected_plugin_path ]
             e=MediaControlException()
             return mediacontrol_new(len(p), p, e)
 
+    def get_media_position(self, origin=PositionOrigin.AbsolutePosition, key=PositionKey.MediaTime):
+        e=MediaControlException()
+        p=mediacontrol_get_media_position(self, origin, key, e)
+        if p:
+            return p.contents
+        else:
+            return None
+
+    def set_media_position(self, pos):
+        """Set the media position.
+
+        @param pos: a MediaControlPosition or an integer (in ms)
+        """
+        if not isinstance(pos, MediaControlPosition):
+            pos=MediaControlPosition(long(pos))
+        e=MediaControlException()
+        mediacontrol_set_media_position(self, pos, e)
+
+    def start(self, pos=0):
+        """Start the player at the given position.
+
+        @param pos: a MediaControlPosition or an integer (in ms)
+        """
+        if not isinstance(pos, MediaControlPosition):
+            pos=MediaControlPosition(long(pos))
+        e=MediaControlException()
+        mediacontrol_start(self, pos, e)
+
+    def snapshot(self, pos=0):
+        """Take a snapshot.
+
+        Note: the position parameter is not properly implemented. For
+        the moment, the only valid position is the 0-relative position
+        (i.e. the current position).
+
+        @param pos: a MediaControlPosition or an integer (in ms)
+        """
+        if not isinstance(pos, MediaControlPosition):
+            pos=MediaControlPosition(long(pos))
+        e=MediaControlException()
+        p=mediacontrol_snapshot(self, pos, e)
+        if p:
+            snap=p.contents
+            # FIXME: there is a bug in the current mediacontrol_snapshot
+            # implementation, which sets an incorrect date.
+            # Workaround here:
+            snap.date=self.get_media_position().value
+            return snap
+        else:
+            return None
+
+    def display_text(self, message='', begin=0, end=1000):
+        """Display a caption between begin and end positions.
+
+        @param message: the caption to display
+        @param begin: the begin position
+        @param end: the end position
+        """
+        if not isinstance(begin, MediaControlPosition):
+            begin=self.value2position(pos)
+        if not isinstance(end, MediaControlPosition):
+            end=self.value2position(end)
+        e=MediaControlException()
+        mediacontrol_display_text(self, message, begin, end, e)
+
+    def get_stream_information(self, key=PositionKey.MediaTime):
+        """Return information about the stream.
+        """
+        e=MediaControlException()
+        return mediacontrol_get_stream_information(self, key, e).contents
+
 class MediaPlayer:
     """Create a new MediaPlayer instance.
 
@@ -101,7 +180,7 @@ class MediaPlayer:
             if p:
                 o.set_media(i.media_new(p[0]))
             return o
-    
+
     def get_instance(self):
         """Return the associated vlc.Instance.
         """
@@ -144,11 +223,14 @@ class LogIterator:
     def next(self):
         if not self.has_next():
             raise StopIteration
-        buffer=LogMessage()
+        buf=LogMessage()
         e=VLCException()
-        ret=libvlc_log_iterator_next(self, buffer, e)
-        return ret
+        ret=libvlc_log_iterator_next(self, buf, e)
+        return ret.contents
 
 class Log:
     def __iter__(self):
         return self.get_iterator()
+
+    def dump(self):
+        return [ str(m) for m in self ]