play music using pygame but no sound

后端 未结 5 1256
情书的邮戳
情书的邮戳 2020-12-16 02:47
import pygame
pygame.mixer.init()
pygame.mixer.music.load(\"only one.mp3\")
pygame.mixer.music.play(0)
while pygame.mixer.music.get_busy():
    pygame.time.Clock().t         


        
5条回答
  •  伪装坚强ぢ
    2020-12-16 03:21

    Pygame sound not working fix

    INFO

    Try reinstalling pygame or upgrading it I had version 1.9.1 which I upgraded to 1.9.3 by the following command

    pip install pygame --upgrade
    

    Note:


    If you install it with easy_install it doesn't work . Not sure but when I tried with easy_install it doesn't work


    The code is the same as yours but i just replaced it with my music file to check it.
    You can see it in the image :

    In this image

    .wav files seem to work well

    I checked it with .mp3 files and found that it does'nt work. You can convert .mp3 to .wav from : Converter

    Or use PyMedia
    If you do not want to convert it using any website.
    You can also convert it with pydub.

    You can download pydub from this

    link

    Or type this command in the command line:

    pip install pydub
    

提交回复
热议问题