1
- Python ctypes-based bindings libvlc
2
- ===================================
1
+ Python ctypes-based bindings for libvlc
2
+ =======================================
3
3
4
4
The bindings use ctypes to directly call the libvlc dynamic lib, and
5
5
the code is generated from the include files defining the public
6
6
API. The same module should be compatible with various versions of
7
7
libvlc 3.*. However, there may be incompatible changes between major
8
8
versions.
9
9
10
- License
11
- -------
12
-
13
- The generated module is licensed, like libvlc, under the GNU Lesser
14
- General Public License 2.1 or later.
15
-
16
10
Installing the module
17
11
---------------------
18
12
@@ -23,55 +17,71 @@ You can install the module through PyPI:
23
17
Using the module
24
18
----------------
25
19
26
- Documentation building needs epydoc. An online build is available at
27
- <http://olivieraubert.net/vlc/python-ctypes/>
28
-
29
20
The module offers two ways of accessing the API - a raw access to all
30
21
exported methods, and more convenient wrapper classes.
31
22
32
23
Using wrapper classes
33
24
+++++++++++++++++++++
34
25
35
26
Most major structures of the libvlc API (Instance, Media, MediaPlayer,
36
- etc) are wrapped as classes, with shorter method names and some
37
- adaptations to provide a more pythonic API:
27
+ etc) are wrapped as classes, with shorter method names and some
28
+ adaptations to provide a more pythonic API:
38
29
39
- >>> import vlc
40
- >>> p= vlc.MediaPlayer('file:///tmp/foo.avi')
41
- >>> p .play()
42
- >>> p .get_instance() # returns the corresponding instance
30
+ >>> import vlc
31
+ >>> player = vlc.MediaPlayer('file:///tmp/foo.avi')
32
+ >>> player .play()
33
+ >>> player .get_instance() # returns the corresponding instance
43
34
44
35
In this case, a default ``vlc.Instance`` will be instanciated and
45
36
stored in ``vlc._default_instance``. It will be used to instanciate
46
37
the various classes (``Media``, ``MediaList``, ``MediaPlayer``, etc).
47
38
48
39
You also can use wrapper methods closer to the original libvlc API:
49
40
50
- >>> import vlc
51
- >>> i= vlc.Instance('--no-audio', '--fullscreen')
52
- >>> p=i .media_player_new()
53
- >>> p .audio_get_volume()
54
- 50
55
- >>> m=i .media_new('file:///tmp/foo.avi')
56
- >>> m .get_mrl()
57
- 'file:///tmp/foo.avi'
58
- >>> p .set_media(m)
59
- >>> p .play()
41
+ >>> import vlc
42
+ >>> instance = vlc.Instance('--no-audio', '--fullscreen')
43
+ >>> player = instance .media_player_new()
44
+ >>> player .audio_get_volume()
45
+ 50
46
+ >>> media = instance .media_new('file:///tmp/foo.avi')
47
+ >>> media .get_mrl()
48
+ 'file:///tmp/foo.avi'
49
+ >>> player .set_media(m)
50
+ >>> player .play()
60
51
61
52
Using raw access
62
53
++++++++++++++++
63
54
64
55
Libvlc methods are available as attributes of the vlc module (as
65
56
vlc.libvlc_*). Use their docstring (any introspective shell like
66
57
ipython is your friend) to explore them, or refer to the online
67
- documentation at http ://olivieraubert.net/vlc/python-ctypes/
58
+ documentation at https ://olivieraubert.net/vlc/python-ctypes/
68
59
69
60
>>> import vlc
70
61
>>> vlc.libvlc_get_version()
71
62
'3.0.0-rc2 Vetinari'
72
- >>> e= vlc.VLCException()
73
- >>> i= vlc.libvlc_new(0, [], e )
74
- >>> i
63
+ >>> exc = vlc.VLCException()
64
+ >>> instance = vlc.libvlc_new(0, [], exc )
65
+ >>> instance
75
66
<vlc.Instance object at 0x8384a4c>
76
- >>> vlc.libvlc_audio_get_volume(i,e )
67
+ >>> vlc.libvlc_audio_get_volume(instance, exc )
77
68
50
69
+
70
+ Example code
71
+ ++++++++++++
72
+
73
+ You can find [example
74
+ files](https://github.com/oaubert/python-vlc/tree/master/examples) in
75
+ the repository.
76
+
77
+ Note that the ``vlc.py`` module can itself be invoked as an
78
+ application using its own features, which also serves as a API usage
79
+ example. See the [end of the
80
+ module](https://github.com/oaubert/python-vlc/blob/master/generated/3.0/vlc.py#L12525)
81
+ after the line ``if __name__ == "__main__":``
82
+
83
+ License
84
+ -------
85
+
86
+ The generated module is licensed, like libvlc, under the GNU Lesser
87
+ General Public License 2.1 or later.
0 commit comments