PyGame에서 mp3를 재생하는 코드가 있습니다. 하지만 스크린 샷 캡처 후 mp3를 재생할 수 없습니다.
file_A.py
from pygame import mixer
mixer.init()
def play(PATH, target):
# play the sound
print("play", target + ".mp3")
mixer.music.load(PATH + target + ".mp3")
mixer.music.play()
play("x","y") // its work if i call here
file_B.py
from .file_A import play
import pyscreenshot as ImageGrab
def main():
play("x1","y") // its working here, but
left = ImageGrab.grab(bbox=(1,2,3,4)) // after grab
play("x2","y") // log printed that method called but sound not working
python 3.7.4
pygame 1.9.6
pyscreenshot 1.0.0
나는 버그가 아닌 주요 문제를 발견했습니다. 하지만 오디오는 이미 실행 된 해당 메서드의 모든 코드와 믹서가 오디오를 재생하기 전에 수행 한 모든 코드를 방해했습니다.
file_B.py
from .file_A import play
import pyscreenshot as ImageGrab
import time
def main():
play("x1","y") // its working here, but
left = ImageGrab.grab(bbox=(1,2,3,4)) // after grab
play("x2","y") // log printed that method called but sound not working
time.sleep(n) // wait the audio play
또는
mixer.play 후에 file_a.py에 추가하십시오.
while mixer.music.get_busy():
time.Clock().tick(10)
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다