playsound3


Nameplaysound3 JSON
Version 3.1.0 PyPI version JSON
download
home_pageNone
SummaryCross-platform library to play audio files
upload_time2025-03-18 22:15:52
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseMIT License
keywords audio media mp3 music play playsound song sound wav wave
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            > **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](https://img.shields.io/badge/dynamic/json?label=latest&query=info.version&url=https%3A%2F%2Fpypi.org%2Fpypi%2Fplaysound3%2Fjson)](https://pypi.org/project/playsound3)
[![PyPI license](https://img.shields.io/badge/dynamic/json?label=license&query=info.license&url=https%3A%2F%2Fpypi.org%2Fpypi%2Fplaysound3%2Fjson)](https://pypi.org/project/playsound3)

Cross platform library to play sound files in Python.

## Installation

Install via pip:

```
pip install playsound3
```

## Quick Start

After installation, playing sounds is simple:

```python
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

```python
def playsound(
    sound: str | Path,
    block: bool = True,
    backend: str | None | SoundBackend | type[SoundBackend] = 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:

```python
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

## Fork information

This repository was originally forked from [playsound](https://github.com/TaylorSMarks/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`!

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "playsound3",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "Szymon Mikler <sjmikler@gmail.com>",
    "keywords": "audio, media, mp3, music, play, playsound, song, sound, wav, wave",
    "author": null,
    "author_email": "Szymon Mikler <sjmikler@gmail.com>, Taylor Marks <taylor@marksfam.com>",
    "download_url": "https://files.pythonhosted.org/packages/65/4e/d56ea7ce6f8f9d73c20d21696184e06a68ac88d5075022265c06621b1d94/playsound3-3.1.0.tar.gz",
    "platform": null,
    "description": "> **Version 3.0.0**\n>\n> New functionalities:\n> * stop sounds by calling `sound.stop()`\n> * check if sound is still playing with `sound.is_alive()`\n\n# playsound3\n\n[![PyPi version](https://img.shields.io/badge/dynamic/json?label=latest&query=info.version&url=https%3A%2F%2Fpypi.org%2Fpypi%2Fplaysound3%2Fjson)](https://pypi.org/project/playsound3)\n[![PyPI license](https://img.shields.io/badge/dynamic/json?label=license&query=info.license&url=https%3A%2F%2Fpypi.org%2Fpypi%2Fplaysound3%2Fjson)](https://pypi.org/project/playsound3)\n\nCross platform library to play sound files in Python.\n\n## Installation\n\nInstall via pip:\n\n```\npip install playsound3\n```\n\n## Quick Start\n\nAfter installation, playing sounds is simple:\n\n```python\nfrom playsound3 import playsound\n\n# Play sounds from disk\nplaysound(\"/path/to/sound/file.mp3\")\n\n# or play sounds from the internet.\nplaysound(\"http://url/to/sound/file.mp3\")\n\n# You can play sounds in the background\nsound = playsound(\"/path/to/sound/file.mp3\", block=False)\n\n# and check if they are still playing\nif sound.is_alive():\n    print(\"Sound is still playing!\")\n\n# and stop them whenever you like.\nsound.stop()\n```\n\n## Reference\n\n### playsound\n\n```python\ndef playsound(\n    sound: str | Path,\n    block: bool = True,\n    backend: str | None | SoundBackend | type[SoundBackend] = None,\n) -> Sound\n```\n\n`sound` (required) \\\nThe audio file you want to play (local or URL).\n\n`block` (optional, default=`True`)\\\nDetermines whether the sound plays synchronously (blocking) or asynchronously (background).\n\n`backend` (optional, default=`None`) \\\nSpecify which audio backend to use.\nIf `None`, the best backend is determined automatically.\n\nTo see a list of backends supported by your system:\n\n```python\nfrom playsound3 import AVAILABLE_BACKENDS, DEFAULT_BACKEND\n\nprint(AVAILABLE_BACKENDS)  # for example: [\"gstreamer\", \"ffmpeg\", ...]\nprint(DEFAULT_BACKEND)  # for example: \"gstreamer\"\n```\n\n### Sound\n\n`playsound` returns a `Sound` object for playback control:\n\n| Method        | Description                               |\n|---------------|-------------------------------------------|\n| `.is_alive()` | Checks if the sound is currently playing. |\n| `.wait()`     | Blocks execution until playback finishes. |\n| `.stop()`     | Immediately stops playback.               |\n\n## Supported systems\n\n* **Linux**\n    * GStreamer\n    * ALSA (aplay and mpg123)\n* **Windows**\n    * WMPlayer\n    * winmm.dll\n* **macOS**\n    * AppKit\n    * afplay\n* **Multiplatform**\n    * FFmpeg\n\n## Fork information\n\nThis repository was originally forked from [playsound](https://github.com/TaylorSMarks/playsound) library created by Taylor Marks.\nThe original library is not maintained anymore and doesn't accept pull requests.\nThis library is a major rewrite of its original.\n\nFeel free to create an issue or contribute to `playsound3`!\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "Cross-platform library to play audio files",
    "version": "3.1.0",
    "project_urls": {
        "Documentation": "https://github.com/sjmikler/playsound3/blob/main/README.md#quick-start",
        "Home": "https://github.com/sjmikler/playsound3",
        "Issues": "https://github.com/sjmikler/playsound3/issues"
    },
    "split_keywords": [
        "audio",
        " media",
        " mp3",
        " music",
        " play",
        " playsound",
        " song",
        " sound",
        " wav",
        " wave"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "c9e2b7f836b1d66c55b569f19d323ba23895f6322115c8e3a79aeb75356ee8ac",
                "md5": "cf60cf4227f0c7fc2e686efc6a1a98ee",
                "sha256": "f5efbc8e66e7e101e5d4617dbb7c6ee459e4d8cf77ce53bb4966cbf71cd14d33"
            },
            "downloads": -1,
            "filename": "playsound3-3.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "cf60cf4227f0c7fc2e686efc6a1a98ee",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 8670,
            "upload_time": "2025-03-18T22:15:51",
            "upload_time_iso_8601": "2025-03-18T22:15:51.918411Z",
            "url": "https://files.pythonhosted.org/packages/c9/e2/b7f836b1d66c55b569f19d323ba23895f6322115c8e3a79aeb75356ee8ac/playsound3-3.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "654ed56ea7ce6f8f9d73c20d21696184e06a68ac88d5075022265c06621b1d94",
                "md5": "e6fef858863e38ba8415a9ddb8712272",
                "sha256": "0c0d3c6ada44d6638c8e1e200fc046ace9509155e050ccb62a6d237bc108c0c3"
            },
            "downloads": -1,
            "filename": "playsound3-3.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "e6fef858863e38ba8415a9ddb8712272",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 7808,
            "upload_time": "2025-03-18T22:15:52",
            "upload_time_iso_8601": "2025-03-18T22:15:52.981357Z",
            "url": "https://files.pythonhosted.org/packages/65/4e/d56ea7ce6f8f9d73c20d21696184e06a68ac88d5075022265c06621b1d94/playsound3-3.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-03-18 22:15:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sjmikler",
    "github_project": "playsound3",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "playsound3"
}
        
Elapsed time: 0.42812s