【问题标题】:Play a WAV melody on Mac在 Mac 上播放 WAV 旋律
【发布时间】:2021-10-13 19:32:39
【问题描述】:

我正在寻找可在 macOS 上运行的 winsound 替代方案,以便我可以创建旋律。我已经尝试过:

import pygame

pygame.init()
pygame.mixer.init()
sounda = pygame.mixer.Sound("desert_rustle.wav")
sounda.play()

但它不起作用......

【问题讨论】:

  • “它不起作用”到底是什么意思?
  • import pygame pygame.init() sound = pygame.mixer.Sound('desert_rustle.wav') pygame.mixer.Sound.play(sound) pygame.time.wait(int(sound.get_length() * 1000))

标签: python macos pygame winsound


【解决方案1】:

我无法在 macOS 上进行测试,但在 PyPI 上搜索后,我发现 boombox 可能适合您,请先安装它

pip install boombox

然后检查它是否在您的机器上工作

from boombox import BoomBox
boombox = BoomBox("desert_rustle.wav")
boombox.play()

如果您需要使用 macOS 的软件包,您可以在 PyPI 浏览器中按操作系统过滤 - PyPI packages with MacOS label

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-03-26
    • 2012-03-04
    • 1970-01-01
    • 2011-03-30
    • 2011-01-30
    • 2017-01-14
    • 1970-01-01
    相关资源
    最近更新 更多