]> git.sesse.net Git - vlc/commitdiff
python-ctypes: improve win32 support
authorOlivier Aubert <olivier.aubert@liris.cnrs.fr>
Tue, 4 Aug 2009 08:54:45 +0000 (10:54 +0200)
committerOlivier Aubert <olivier.aubert@liris.cnrs.fr>
Tue, 4 Aug 2009 09:36:35 +0000 (11:36 +0200)
bindings/python-ctypes/footer.py
bindings/python-ctypes/header.py

index 2d00aba9815dd053002bdeac2ba4596b8def8fff..90fd81ae6d722cd310953e1de5a08fbb1e02abb9 100644 (file)
@@ -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)
index 6d63da78076bc810eab2abd7ef73c244780383fb..046aedc68643f4f381ffdfb239f8c170333505de 100755 (executable)
@@ -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')