[vlc-devel] commit: python-ctypes: improve win32 support (Olivier Aubert )

git version control git at videolan.org
Tue Aug 4 11:37:54 CEST 2009


vlc | branch: master | Olivier Aubert <olivier.aubert at liris.cnrs.fr> | Tue Aug  4 10:54:45 2009 +0200| [07aea02299cac2bece83c763563932f8ea591ded] | committer: Olivier Aubert 

python-ctypes: improve win32 support

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=07aea02299cac2bece83c763563932f8ea591ded
---

 bindings/python-ctypes/footer.py |    6 +++++-
 bindings/python-ctypes/header.py |   16 +++++++++++++++-
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/bindings/python-ctypes/footer.py b/bindings/python-ctypes/footer.py
index 2d00aba..90fd81a 100644
--- a/bindings/python-ctypes/footer.py
+++ b/bindings/python-ctypes/footer.py
@@ -66,7 +66,10 @@ if __name__ == '__main__':
         sys.exit(0)
 
     if sys.argv[1:]:
-        i=Instance()
+        if sys.platform == 'win32' and plugin_path is not None:
+            i=Instance('--plugin-path', plugin_path)
+        else:
+            i=Instance()
         m=i.media_new(sys.argv[1])
         p=i.media_player_new()
         p.set_media(m)
@@ -111,6 +114,7 @@ if __name__ == '__main__':
             'q': quit,
             }
 
+        print "Press q to quit, ? to get help."
         while True:
             k=getch()
             method=keybindings.get(k, None)
diff --git a/bindings/python-ctypes/header.py b/bindings/python-ctypes/header.py
index 6d63da7..046aedc 100755
--- a/bindings/python-ctypes/header.py
+++ b/bindings/python-ctypes/header.py
@@ -41,7 +41,21 @@ build_date="This will be replaced by the build date"
 if sys.platform == 'linux2':
     dll=ctypes.CDLL('libvlc.so')
 elif sys.platform == 'win32':
-    dll=ctypes.CDLL('libvlc.dll')
+    import ctypes.util
+    import os
+    plugin_path=None
+    path=ctypes.util.find_library('libvlc.dll')
+    if path is None:
+        # Try a standard location.
+        p='c:\\Program Files\\VideoLAN\\VLC\\libvlc.dll'
+        if os.path.exists(p):
+            plugin_path=os.path.dirname(p)
+            os.chdir(plugin_path)
+        # If chdir failed, this will not work and raise an exception
+        path='libvlc.dll'
+    else:
+        plugin_path=os.path.dirname(path)
+    dll=ctypes.CDLL(path)
 elif sys.platform == 'darwin':
     # FIXME: should find a means to configure path
     dll=ctypes.CDLL('/Applications/VLC.app/Contents/MacOS/lib/libvlc.2.dylib')




More information about the vlc-devel mailing list