Skip to main content

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

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, …)

Metadata

Release files for anyplayer 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for anyplayer 0.0.7
File Size Uploaded
anyplayer-0.0.7.tar.gz 11.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for anyplayer 0.0.7
File Interpreter ABI Platform
anyplayer-0.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 24.8 kB

Release files / anyplayer-0.0.7.tar.gz

Download URL anyplayer-0.0.7.tar.gz
Size 11.2 kB
Tags Source
SHA-256 checksum
How to use checksums
50b16c28326cde9f31f6b1198ea2cb6b900f4688c9bfda4aa7eaa166289091a3
BLAKE2b-256 checksum
How to use checksums
b2abd98854021350d3dd623cd845601442a1a0a8b4ff69b64ef8b0786c75bd5c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.1.dev0+g94f810c.d20240510 CPython/3.12.6

Release files / anyplayer-0.0.7-py3-none-any.whl

Download URL anyplayer-0.0.7-py3-none-any.whl
Size 13.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6b5439efe53c59bea892e30f4a5240315105e7e270b6673644df451421cfe3ba
BLAKE2b-256 checksum
How to use checksums
68da677bc0e1bc1b78ecbc34b8e4e09b7117a2b87eaae7f7137834af53406ed0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.1.dev0+g94f810c.d20240510 CPython/3.12.6

Release history Release notifications | RSS feed

This release

0.0.7 This release

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page