2017-02-18 1 views
0

작업 pycharm에 Mac에서 파이 게임에서 사운드 또는 음악을 가져올 수 없습니다,이내가 음악이나 소리와 함께 작동하는 파이 게임을 얻을 수

import pygame 
pygame.init() 
pygame.mixer.init() 
song = pygame.mixer.Sound('/Users/Me/PycharmProjects/Porting Tester/MusicTest/Hi.mp3') 
display = pygame.display.set_mode((800, 600)) 
pygame.display.set_caption("Hi") 
clock = pygame.time.Clock() 
song.play() 
while True: 
    for event in pygame.event.get(): 
     if event.type == pygame.QUIT: 
      pygame.quit() 
      quit() 
      exit() 
    pygame.display.update() 
    clock.tick(60) 
pygame.quit() 

시도했지만 그 말을 오류가 발생합니다 :

Python(18309,0x7fff73a5f000) malloc: *** error for object 0x1004dae80: pointer being freed was not allocated *** 
set a breakpoint in malloc_error_break to debug 

그리고

Process finished with exit code 134 (interrupted by signal 6: SIGABRT) 

의 반환 값은 나는 많은 것들을 시도했지만 나는 그것이 나에게 이러한 오류를주고 파일 생각 . 이 정확한 코드와

+0

다른 사운드 파일을 사용해 보셨습니까? –

+0

예, 다른 태그 (.wav) –

답변

0

: 나는 (파이썬 파일과 같은 폴더에 위치) 파일, ts.wav을 재생할 수 있었고, 제대로 작용

import pygame 
import os 
pygame.init() 
pygame.mixer.pre_init(44100, 16, 2, 4096) # Frequency, channel size, channels, buffersize 
pygame.mixer.init() 

song = pygame.mixer.Sound('ts.wav') 

display = pygame.display.set_mode((800, 600)) 
pygame.display.set_caption("Hi") 
clock = pygame.time.Clock() 

song.play() 

while True: 
    for event in pygame.event.get(): 
     if event.type == pygame.QUIT: 
      pygame.quit() 
      quit() 
      exit() 
    pygame.display.update() 
    clock.tick(60) 
pygame.quit() 

.

내가 한 것처럼 보이는 유일한 것은 pygame.mixer.pre_init(44100, 16, 2, 4096)을 추가하고 사운드의 위치를 ​​이동하는 것입니다.

여전히이 작동하지 않으면 PyCharm 일 수 있습니다. 수 있습니다. 나는 과거에 그것을 사용했고 이상했다.

관련 문제