Skip to main content

Version 3.0.0

New functionalities:

  • stop sounds by calling sound.stop()
  • check if sound is still playing with sound.is_alive()

playsound3

PyPi version PyPI license

Cross platform library to play sound files in Python.

Installation

Install via pip:

pip install playsound3

Quick Start

After installation, playing sounds is simple:

from playsound3 import playsound

# Play sounds from disk
playsound("/path/to/sound/file.mp3")

# or play sounds from the internet.
playsound("http://url/to/sound/file.mp3")

# You can play sounds in the background
sound = playsound("/path/to/sound/file.mp3", block=False)

# and check if they are still playing
if sound.is_alive():
    print("Sound is still playing!")

# and stop them whenever you like.
sound.stop()

Reference

playsound

def playsound(
    sound: str | Path,
    block: bool = True,
    backend: str | None = None,
) -> Sound

sound (required)
The audio file you want to play (local or URL).

block (optional, default=True)
Determines whether the sound plays synchronously (blocking) or asynchronously (background).

backend (optional, default=None)
Specify which audio backend to use. If None, the best backend is determined automatically.

To see a list of backends supported by your system:

from playsound3 import AVAILABLE_BACKENDS, DEFAULT_BACKEND

print(AVAILABLE_BACKENDS)  # for example: ["gstreamer", "ffmpeg", ...]
print(DEFAULT_BACKEND)  # for example: "gstreamer"

Sound

playsound returns a Sound object for playback control:

Method Description
.is_alive() Checks if the sound is currently playing.
.wait() Blocks execution until playback finishes.
.stop() Immediately stops playback.

Supported systems

  • Linux
    • GStreamer
    • ALSA (aplay and mpg123)
  • Windows
    • WMPlayer
    • winmm.dll
  • macOS
    • AppKit
    • afplay
  • Multiplatform
    • FFmpeg

Supported audio formats

The bare minimum supported by every backend are .mp3 and .wav files. Using them will keep your program compatible across different systems. To see an exhaustive list of extensions supported by a backend, refer to their respective documentation.

Fork information

This repository was originally forked from playsound library created by Taylor Marks. The original library is not maintained anymore and doesn't accept pull requests. This library is a major rewrite of its original.

Feel free to create an issue or contribute to playsound3!

Metadata

Release files for playsound3 3.3.2

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

Source distribution (sdist)

Source distribution for playsound3 3.3.2
File Size Uploaded
playsound3-3.3.2.tar.gz 608.8 kB Details

Built distribution (wheel)

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

Total release size: 618.6 kB

Release files / playsound3-3.3.2.tar.gz

Download URL playsound3-3.3.2.tar.gz
Size 608.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a19d9f542beb3ce5ecb4ca780b47092c785725263e339bed8e7d340b322c4f9d
BLAKE2b-256 checksum
How to use checksums
f8dacad7906fffd15c13db1ee02054e0d59d86711e366947f05bc9a2e9da0e8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.14

Release files / playsound3-3.3.2-py3-none-any.whl

Download URL playsound3-3.3.2-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fde2ca4378ae7a34d125a5965799fb1eee2af9907dbec29d394e29d28ee4137b
BLAKE2b-256 checksum
How to use checksums
8b3993f689120673873a1328fbf94b6906a16b5ada41f33af0699f2eddc73cff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

3.3.2 This release

2 release files

3.3.1

2 release files

3.3.0

2 release files

3.2.8

2 release files

3.2.7

2 release files

3.2.6

2 release files

3.2.5

2 release files

3.2.4

2 release files

3.2.3

2 release files

3.2.2

2 release files

3.2.1

2 release files

3.2.0

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.2

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.6.0

2 release files

2.5.2

2 release files

2.5.1

2 release files

2.5.0

2 release files

2.4.0

2 release files

2.3.0

2 release files

2.2.3

2 release files

2.2.2

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.6

2 release files

2.1.5

2 release files

2.1.4

2 release files

2.1.2

2 release files

2.1.1

2 release files

2.1.0

1 release file

2.0.4

1 release file

2.0.3

1 release file

2.0.2

1 release file

2.0.1

1 release file

2.0.0

1 release file

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