Skip to content

Instantly share code, notes, and snippets.

@jaseg
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaseg/83d65e81729a45608770 to your computer and use it in GitHub Desktop.
Save jaseg/83d65e81729a45608770 to your computer and use it in GitHub Desktop.
Interfacing with mpv from python via ctypes
newton~ <3 ipython3
Python 3.4.1 (default, May 19 2014, 17:23:49)
Type "copyright", "credits" or "license" for more information.
IPython 2.1.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: import ctypes
In [2]: mpv = ctypes.CDLL('libmpv.so')
In [3]: mpv.mpv_create.restype = ctypes.c_void_p
In [4]: mpvh = mpv.mpv_create()
In [5]: mpv.mpv_initialize(mpvh)
Out[5]: 0
In [6]: _TempArgT = ctypes.c_char_p*3
In [7]: args = _TempArgT(b'loadfile', b'/data/jaseg/music/Tight Sweater by Marc Mellits (live cover).ogg', ctypes.c_char_p())
In [8]: mpv.mpv_command(mpvh, args)
Out[8]: 0
In [9]:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment