A simple, minimal-hassle, few-dependency Python audio playback solution
Project description
A simple, minimal-hassle, few-dependency Python audio playback solution.
Play audio using any of the optional dependencies you have installed.
Options (clink to see installation instructions): ffplay mpv vlc mpg123 cmus gst aplay simpleaudio pyaudio playsound filemgr elisa (and auto)
Note: If you prefer the most convenient audio playback on a modern PC and don’t mind the additional hard disk space (less than 256 MB), choose the optional dependency ffplay.
Usage Guidelines
Installation:
pip install anyplayer
Simple Example:
from anyplayer import get_player
player = get_player('auto', './ba.mp3')
player.start()
player.wait()
Optional Dependencies
ffplay mpv vlc mpg123 cmus gst aplay simpleaudio pyaudio playsound filemgr elisa
FFmpeg (Recommended)
FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video.
Windows: Download binaries from BtbN/FFmpeg-Builds GitHub Releases (and add it to your PATH).
Linux:
pacman -Syu ffmpeg
# or
apt install ffmpeg
mpv (Recommended)
mpv is a free, open source, and cross-platform media player.
Windows: Download binaries from First-party builds (and add it to your PATH).
Linux:
pacman -Syu mpv
# or
apt install mpv
VLC
VLC is a free and open source cross-platform multimedia player and framework that plays most multimedia files as well as DVDs, Audio CDs, VCDs, and various streaming protocols.
Linux:
pacman -Syu vlc
# or
apt install vlc
mpg123
mpg123 is a fast console MPEG Audio Player and decoder library.
Windows: Download binaries from First-party (and add it to your PATH).
Linux:
pacman -Syu mpg123
# or
apt install mpg123
cmus
cmus is a small, fast and powerful console music player for Unix-like operating systems.
Linux:
pacman -Syu cmus
Note: To use the optional player cmus, ensure cmus is running in a separate terminal session.
Gst
gst-plugins-base-libs is a multimedia graph framework.
Linux:
pacman -Syu gst-plugins-base-libs
ALSA aplay
aplay is an utility for the playback of .wav, .voc, .au files. It’s included in the official alsa-utils package.
Linux:
pacman -Syu alsa-utils
simpleaudio
The simplaudio package provides cross-platform, dependency-free audio playback capability for Python 3 on OSX, Windows, and Linux.
pip install simplaudio
# or
pacman -Syu python-simpleaudio
Note: Unfortunately, simpleaudio has been archived and unmaintained for over three years. It has known bugs and compatibility issues with Python 3.12 or later.
(A segmentation fault will occur when audio playback is completed or aborted. This can be used if you are only playing once and have no other tasks after the playback stops.)
Additionally, on Windows, ensure you call multiprocessing.freeze_support() immediately after the if __name__ == '__main__': line in the main module:
# main.py
import multiprocessing
...
if __name__ == '__main__':
multiprocessing.freeze_support()
...
PyAudio
PyAudio provides Python bindings for PortAudio v19, the cross-platform audio I/O library.
pip install pyaudio
# or
conda install pyaudio portaudio
# or
pacman -Syu python-pyaudio
Note: The optional module pyaudio may fail to play 64-bit WAV files, as the wave module does not support 64-bit WAV audio.
Additionally, on Linux, pyaudio may produce significant noise during playback.
playsound
playsound is a pure Python, cross platform, single-function module with no dependencies for playing sounds.
Note: However, as the original module is no longer maintained and doesn’t accept pull requests, we use playsound3 as an alternative.
pip install playsound3
File Manager
Invokes the default file manager directly.
Windows: explorer.exe.
Linux: dolphin or xdg-open.
Note: filemgr directly invokes the default file manager so may not exit cleanly.
Elisa
Elisa is the default music player for KDE.
To do
More information specific to OSX (optional dependencies, testing, …)
Project details
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file anyplayer-0.0.7.tar.gz.
File metadata
- Download URL: anyplayer-0.0.7.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.1.dev0+g94f810c.d20240510 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50b16c28326cde9f31f6b1198ea2cb6b900f4688c9bfda4aa7eaa166289091a3
|
|
| MD5 |
050a3580798d9250301efa791410975c
|
|
| BLAKE2b-256 |
b2abd98854021350d3dd623cd845601442a1a0a8b4ff69b64ef8b0786c75bd5c
|
File details
Details for the file anyplayer-0.0.7-py3-none-any.whl.
File metadata
- Download URL: anyplayer-0.0.7-py3-none-any.whl
- Upload date:
- Size: 13.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.1.dev0+g94f810c.d20240510 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b5439efe53c59bea892e30f4a5240315105e7e270b6673644df451421cfe3ba
|
|
| MD5 |
bf05f31a2473b88a4bce54b38b792a93
|
|
| BLAKE2b-256 |
68da677bc0e1bc1b78ecbc34b8e4e09b7117a2b87eaae7f7137834af53406ed0
|