简体   繁体   English

为什么我收到此Pygame音乐错误?

[英]Why am I getting this Pygame Music Error?

pygame.mixer.music.load('audio/zombie_theme.ogg')
pygame.error: Unrecognized music format

there is the error. 有错误。 As you can see I am using an ogg file. 如您所见,我正在使用ogg文件。 Here is the code: 这是代码:

import pygame, sys, Funk
from tileC import Tile
from object_classes import *
from interaction import interaction
from A_Star import A_Star

pygame.init()
pygame.font.init()
pygame.mixer.init()

pygame.mixer.music.load('audio/zombie_theme.ogg')
pygame.mixer.music.play(-1)

Any ideas? 有任何想法吗? Thanks. 谢谢。

Try with this if you want the background to infinite loop: 如果您希望背景无限循环,请尝试以下方法:

pygame.mixer.music.load('audio/zombie_theme.ogg')
pygame.mixer.music.play(-1, 0.0)

Or this if you want it to play only one time: 如果您只希望播放一次,则此操作:

pygame.mixer.music.load('audio/zombie_theme.ogg')
pygame.mixer.music.play()

(I'm still new to python so i don't know if this will work for you, for me it work) (我对python还是很陌生,所以我不知道这是否对您有用,对我来说它有用)

Oh yeah, and have you tried to set up a window? 哦,是的,您尝试设置一个窗口吗? because i think it can't really work if you don't set up a window. 因为我认为如果您不设置窗口,它将无法真正起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM