音频未加载

时间:2018-09-01 17:01:45

标签: python file audio pygame python-3.4

我经常使用pygame,但以前从未使用过声音。我已经检查过,并且文件的名称正确,并且使用了正确的路径,但是我只收到以下错误消息:

回溯(最近通话最近):
  模块中第11行的文件“ C:\ Users \ Rajive \ AppData \ Local \ Programs \ Python \ Python3.4.3 \ DCW.py”     door_opening = pygame.mixer.Sound('C:\ Users \ Rajive \ Downloads \ door_opening.m4a')
pygame.error:无法打开文件'C:\ Users \ Rajive \ Downloads \ door_opening.m4a'

import random, time, pygame
time = time.clock()
pygame.init()
diff = 1
door_opening =  pygame.mixer.Sound('C:\\Users\\Rajive\\Downloads\\door_opening.m4a')
door_closing =  pygame.mixer.Sound('C:\\Users\\Rajive\\Downloads\\door_closing.m4a')
closet_opening =  pygame.mixer.Sound('C:\\Users\\Rajive\\Downloads\\closet_opening.m4a')
closet_opening =  pygame.mixer.Sound('C:\\Users\\Rajive\\Downloads\\closet_closing.m4a')
window_opening =  pygame.mixer.Sound('C:\\Users\\Rajive\\Downloads\\window_opening.m4a')
window_opening =  pygame.mixer.Sound('C:\\Users\\Rajive\\Downloads\\window_closing.m4a')

1 个答案:

答案 0 :(得分:1)

来自pygame documentation:

  

可以从OGG音频文件或未压缩的WAV加载声音。

看起来不支持.m4a编解码器。也许先尝试转换文件。