Cross-platform library to play audio files
Project description
playsound3
Cross platform library to play sound files in Python.
Installation
Install via pip:
pip install playsound3
Quick Start
Once installed, you can use the playsound function to play sound files:
from playsound3 import playsound
playsound("/path/to/sound/file.mp3")
# or use directly on URLs
playsound("http://url/to/sound/file.mp3")
Documentation
The playsound3
module contains a single function named playsound
:
def playsound(sound, block=True, backend=None) -> None:
"""Play a sound file using an audio backend availabile in your system.
Args:
sound: Path or URL to the sound file. Can be a string or pathlib.Path.
block: If True, the function will block execution until the sound finishes playing.
If False, sound will play in a background thread.
backend: Name of the audio backend to use. Use None for automatic selection.
"""
...
It requires one argument: sound
- the path to the file with the sound you'd like to play.
This should be a local file or a URL.
There's an optional second argument: block
which is set to True
by default.
Setting it to False
makes the function run asynchronously.
You can manually specify a backend by passing its name as the third argument.
You can browse available backends by using playsound3.AVAILABLE_BACKENDS
.
It is recommended to use the default value of None
to let the library choose the best backend available.
Supported systems
- Linux using one of the below backends, whichever is available:
- GStreamer
- FFmpeg
- aplay for .wav and mpg123 .mp3
- Windows using winmm.dll (built-in on Windows)
- OS X using afplay utility (built-in on OS X)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for playsound3-2.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b93daa11a638dcf04792b12505a1928b8b6cb6b5665219499ef531d1647bc60 |
|
MD5 | cdf3caaaefaf54c1b004ed99c64e0710 |
|
BLAKE2b-256 | 24caacef0503ffc253b8cdeaf7b1531dd0cf5a518b2913e5caed159c49595f2b |