加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

playsound

Pure Python, cross platform, single function module with no dependencies for playing sounds.

Installation

Install via pip:

$ pip install playsound

Done.

If you insist on the (slightly) harder way of installing, from source, you know how to do it already and don't need my help.

The latest version of the source code can be found at: https://github.com/TaylorSMarks/playsound

Quick Start

Once you've installed, you can really quickly verified that it works with just this:

>>> from playsound import playsound
>>> playsound('/path/to/a/sound/file/you/want/to/play.mp3')

Documentation

The playsound module contains only one thing - the function (also named) playsound.

It requires one argument - the path to the file with the sound you'd like to play. This may 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.

On Windows, uses windll.winmm. WAVE and MP3 have been tested and are known to work. Other file formats may work as well.

On OS X, uses AppKit.NSSound. WAVE and MP3 have been tested and are known to work. In general, anything QuickTime can play, playsound should be able to play, for OS X.

On Linux, uses GStreamer. Known to work on Ubuntu 14.04 and ElementaryOS Loki. I expect any Linux distro with a standard gnome desktop experience should work.

If you'd like other Linux distros (or any other OS) to work, submit a PR adding in support for it, but please make sure it passes the tests (see below).

Testing

Playsound includes a small set of tests - if you're making a PR, please ensure that you have no regressions and all the tests pass on your local system. Also make sure that Travis-CI, which runs these tests against Windows Server 2016, macOS 10.11 (El Capitan, 2015) and 11.3 (Big Sur, 2020), Ubuntu 14 (Trusty), and Ubuntu 18 (Bionic), for both Python 2.7 and 3.9, fully passes. You can check the Travis-CI status for Playsound here: https://travis-ci.com/github/TaylorSMarks/playsound/builds

Copyright

This software is Copyright (c) 2021 Taylor Marks <taylor@marksfam.com>.

See the bundled LICENSE file for more information.

The MIT License (MIT) Copyright (c) 2021 Taylor Marks <taylor@marksfam.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ################################################################## Files used for Unit Tests were downloaded from Wikimedia Commons - they and their licenses can be found at the following urls. I am not a lawyer, but it's my belief that as these files are merely used for unit testing and in no way necessary for using playsound that playsound can be distributed under the more permissive (supperior, actual free) MIT license and that the cancerous copyleft bullshit from the Creative Commons licenses that most of the files have: - https://commons.wikimedia.org/wiki/File:Damonte.mp3 - https://commons.wikimedia.org/wiki/File:Sound4.wav - https://commons.wikimedia.org/wiki/File:%D0%91%D1%83%D0%BA%D0%B2%D0%B0_%D0%AF.wav - https://commons.wikimedia.org/wiki/File:Discovery_-_Go_at_throttle_up_(2).mp3

简介

https://github.com/TaylorSMarks/playsound.git 展开 收起
Python
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化