GithubHelp home page GithubHelp logo

pymplb's Introduction

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 (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 discovered at runtime and thus these bindings should automatically also support any new commands added to MPlayer in the future. An example:

>>> 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 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 slave-mode documentation 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_')
>>> player = MPlayer3()
>>> player.m_loadfile('test.ogv')
>>> player.prop_filename
'test.ogv'

Support the developer if you like this project:

Donate using Liberapay

pymplb's People

Contributors

ext avatar pafcu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

ext jacek64 lefedor

pymplb's Issues

How to seek when playing stream?

player.seek(15,2) works fine with local files (begin playing at 15 secs) but is ignored when streaming.
How can I start a stream at 15 secs?
Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.