Package: libwinmedia
libwinmedia-pyPython bindings forlibwinmedia, a tiny yet powerful media playback library for Windows and Linux.This library's goal is to make a beginner-friendly, easy-to-use API with many advanced features.DependenciesThis library has NO DEPENDENCIES on Windows, except for C++ library.Linux on the other hand requires some packages to be installed:pygobject- This allows us to interact withGTK. This will be automatically installed when you install our library.libgirepository1.0-dev- This dependency allows us to interact withGTKthroughPyGObjectpython3-dev- This is required to buildPyGObjectlibwebkit2gtk-4.0-dev- This is required to summon the player in WebKit.You can install this dependencies using this command on Debian/Ubuntu based operating systems:sudo apt install libgirepository1.0-dev python3-dev libwebkit2gtk-4.0-devAfter you installed this, you may proceed installing libwinmedia (see next step)InstallationYou can install latest stable version from PyPI using this command:pipinstalllibwinmediaYou can install the latest version from Git using this command:pipinstallgit+https://github.com/libwinmedia/libwinmedia-pyThis source might be more stable in some cases, but can be less stable than latest PyPI releaseRequirementsYou need to download a libwinmedia.dll for Windows or libwinmedia.so for Linux from thereleases pageand set it up properly. You can either put it somewhere in the%PATH%or set theLIBWINMEDIA_PATHenvironment variable.On Linux, I recommend using LIBWINMEDIA_PATH environment variable, since there were some troubles finding library in Pythonctypeslibrary.Another way to deal with it is to ship libwinmedia shared library with your script and put the directory where your script is located in %PATH% before importing the library:importosos.environ["PATH"]=os.path.dirname(__file__)+os.pathsep+os.environ["PATH"]If libwinmedia.dll (or libwinmedia.so) is located elsewhere, you can add that path toos.environ["PATH"].Linux limitationsWhile Linux support is amazing, it comes with some limitations.For example, you can't use NativeControls class, tags_from_music & tags_from_video functions in Player class.Otherwise, everything should work!Simple startimportlibwinmediaplayer=libwinmedia.Player()media=libwinmedia.Media("https://archive.org/download/Kalimba.mp3_377/Kalimba.mp3")player.open(media)When you don't need any of the created instances, you can dispose them to free up system resources:player.dispose()media.dispose()Important!The program containing playing media must not exit before player is done playing.To do this in examples we recommend adding this at the end:whileTrue:passPlaylistsYou can open player (player.open()) withPlaylistinstance or withMediainstance.If you open Player with Media, then it will play only one song, but if you open
it with Playlist, then it will create a playlist and play it like that...Simple example:importlibwinmediaplayer=libwinmedia.Player()media1=libwinmedia.Media("media1.ogg")media2=libwinmedia.Media("media2.ogg")playlist=libwinmedia.Playlist(media1,media2)player.open(playlist)ParametersYou have access to these parameters of thePlayerinstance:loopingautoplayaudio_balanceratevolumepositionCallbacksThis library provides callbacks. You need to decorate your functions as follows:@player.volume_callback()defcallback(volume:float):print("Volume callback: "+str(volume*100))Callback decoratorType, returned from functionvolume_callbackfloat (between 0 and 1, thus you might have to multiply it by 100)rate_callbackfloat (between 0 and 1, thus you might have to multiply it by 100)completed_callbackboolposition_callbackint (in milliseconds)duration_callbackint (in milliseconds)TODO:Implement NativeControlsImplement Video supportLicenseThanks to@alexmercerind. He created one of best libraries for playback, that work with Linux and Windows.He didn't want to put any restrictions on it, so he used a MIT License.
I also don't want to put any restrictions on Python binding, so I kept MIT License.You can find license inLICENSEfileSupport this projectShow some love to this project and consider starring the repository & check out a wholelibwinmediasuite.While you are at it, you can check alsoHarmonoidproject. If you like this library, then share it.Special thanks to@alexmercerindforC++ library.
Without this library, this project wouldn't exist.Huge thanks also to@raitonoberufor his massive contributions to Python bindings.
He has brought current easy-to-use design to this library.DocumentationThis repository includes an example file, called example.pyIn it, there is used almost every function this library provides.Every function is documented (in code or in this file).