mk-fg / python-pulse-control

Python high-level interface and ctypes-based bindings for PulseAudio (libpulse)
https://pypi.org/project/pulsectl/
MIT License
170 stars 36 forks source link

Implement sample play command #36

Closed mraerino closed 4 years ago

mraerino commented 4 years ago

This exposes the c api command pa_context_play_sample from the library

the volume parameter is actually different than in other commands so I decided to always pass "keep volume".

mk-fg commented 4 years ago

Thanks.

I'll probably tweak it a bit to not have extra _method there, accept None as default sink and volume as the usual float arg.

mk-fg commented 4 years ago

Also, wonder if you might want to use libcanberra for such samples instead - check it out, if you haven't.

mraerino commented 4 years ago

thanks for the really fast merge! are you going to do a release?

mk-fg commented 4 years ago

Yup, just did, should be 20.1.2 on pypi (when it updates its caches).

mk-fg commented 4 years ago

Check out 47767121 btw for changes in the fuction signature. Should work with same args as you had though, but sink is optional (None = default one) and allows for volume/proplist.

mk-fg commented 4 years ago

Loading sample via pulse API is probably way too complicated for this module, as you'd probably want to look it up in XDG theme dirs, add some proplist stuff from that, then decode whatever format (mp3, ogg, flac, wav, etc) and send that to pulse in async fashion, but guess you already do loading via some other means.