【问题标题】:Timer with Audio release带音频释放的计时器
【发布时间】:2017-10-06 14:23:37
【问题描述】:

我创建了一个具有特定条件的计时器,当它用完时,它应该释放一个音频。

我的输入:

import time
import playsound
run = raw_input("Start? > ")
mins = 0
# Only run if the user types in "start"
if run == "start":
    # Loop until we reach 2 minutes running
    while mins != 2:
        print ">>>>>>>>>>>>>>>>>>>>>", mins

        if mins ==2:
            playsound.playsound('C:\Audio.mp3', True)

        time.sleep(60)
        # Increment the minute total
        mins += 1

但遗憾的是它并没有发布任何东西

【问题讨论】:

  • 你为什么不睡120秒然后播放声音?

标签: python audio time timer


【解决方案1】:

使用您已经在脚本中使用的time.sleep() 函数在两分钟后播放声音不是更容易吗?

类似于以下内容:

import time
import playsound

time.sleep(120)

playsound.playsound("C:\Audio.mp3", True)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-08-23
    • 2019-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-05
    • 1970-01-01
    相关资源
    最近更新 更多