-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make python3 compatible and update README.md
- Loading branch information
Showing
3 changed files
with
58 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,48 @@ | ||
pymplb (PYthonMPLayerBindings) is a library that can be used to play media using an external MPlayer process. | ||
To use pymplb you must have Python 2.6 or newer and MPlayer installed. | ||
To use pymplb you must have Python 2.6 or newer (Python3 should also work) and MPlayer installed. | ||
The library runs the MPlayer binary in slave mode as a subprocess and then sends slave-mode commands to the process. | ||
Commands are mapped to class methods and properties to class properties (by default prefixed with 'p_'). | ||
Commands are mapped to class methods and properties to class properties (by default prefixed with 'p\_'). | ||
Commands are discovered at runtime and thus these bindings should automatically also support any new commands added to MPlayer in the future. | ||
An example: | ||
|
||
>>> import pymplb;import sys | ||
>>> player = pymplb.MPlayer(fs=True,speed=2.0) | ||
``` | ||
>>> import pymplb | ||
>>> player = pymplb.MPlayer() | ||
>>> player.loadfile('test.ogv') | ||
>>> player.p_filename | ||
'test.ogv' | ||
``` | ||
|
||
All available commands and properties can be used in this way. To see a complete list you can use the python interactive help. All methods take an additional keyword argument 'pausing'. This can be one if 'pausing', 'pausing_keep', 'pausing_toggle', and 'pausing_keep_force'. These affect how playback is affected by the command. | ||
>>> player.get_property('filename',pausing='pausing') | ||
All available commands and properties can be used in this way. To see a complete list you can use the python interactive help. All methods take an additional keyword argument 'pausing'. This can be one of '', 'pausing', 'pausing\_keep', 'pausing\_toggle', and 'pausing\_keep\_force'. These affect how playback is affected by the command. | ||
|
||
``` | ||
>>> player.get_property('filename', pausing='pausing') | ||
'test.ogv' | ||
``` | ||
|
||
See the MPlayer documentation for details on pausing. | ||
See the MPlayer [slave-mode documentation](http://www.mplayerhq.hu/DOCS/tech/slave.txt) for details on pausing. | ||
|
||
By default pymplb assumes that the binary "mplayer" is in your path. If this is not the case, or you want to use a differently named binary, you can do | ||
|
||
``` | ||
>>> MPlayer2 = pymplb.make_mplayer_class(mplayer_bin='/usr/bin/mplayer') | ||
>>> player = MPlayer2() | ||
``` | ||
|
||
This is especially important when using the Windows OS since most programs are NOT in the path. | ||
|
||
The reason why a new class is constructed instead of simply giving the binary path when constructing an MPlayer instance is that introspection capabilities would suffer: it would not be possible to see help for the class until an instance has been constructed. Anyway, this is a minor issue and in general you do not need to worry about this. | ||
|
||
To prevent naming collisions between properties and methods the prefix 'p_' is by default prepended to all property names. It is, however, not impossible that future version of MPlayer could have a property called 'foo' and a command called 'p_foo', which would result in a naming conflict in pymplb. Therefore, it is also possible to change the prefix: | ||
>>> MPlayer3 = pymplb.make_mplayer_class(method_prefix='m_',property_prefix='prop_') | ||
To prevent naming collisions between properties and methods the prefix 'p\_' is by default prepended to all property names. It is, however, not impossible that future version of MPlayer could have a property called 'foo' and a command called 'p\_foo', which would result in a naming conflict in pymplb. Therefore, it is also possible to change the prefix: | ||
|
||
``` | ||
>>> MPlayer3 = pymplb.make_mplayer_class(method_prefix='m_', property_prefix='prop_') | ||
>>> player = MPlayer3() | ||
>>> player.m_loadfile('test.ogv') | ||
>>> player.prop_filename | ||
'test.ogv' | ||
|
||
``` | ||
|
||
Support the developer if you like this project: | ||
bitcoin:1NXsx6mXPNJwnMB2oPpwAdNYGFfMG5WHTd | ||
|
||
[](https://liberapay.com/saparvia/donate) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters