1

I get this error and I don't know why. I am using Visual Studio Code:

pygame.mixer.music.play(loops=-1, start=0.0, fade_ms=4000) TypeError: function takes at most 2 keyword arguments (3 given)

I have this code in a part of my game:

pygame.mixer.music.load(os.path.join("assets", "game_music.wav"))
pygame.mixer.music.play(loops=-1, start=0.0, fade_ms=4000)
pygame.mixer.music.set_volume(0.3)

I also have:

import pygame
import os
from pygame import mixer

pygame.mixer.pre_init(44100, -16, 2, 512)
mixer.init()
pygame.init()

I want to have all 3 arguments. It should work according to https://www.pygame.org/docs/ref/music.html#pygame.mixer.music.play Can someone help me please?

  • 2
    From the documentation `Changed in pygame 2.0.0: Added optional fade_ms argument`, which version of pygame do you use? If it's lower than 2.0.0 just remove the `fade_ms` argument – ChatterOne Jul 29 '22 at 08:29
  • 1
    You can find your pygame version by running `pip show pygame` in the command line prompt. – The_spider Jul 29 '22 at 12:35
  • Thank you!! I had to update my version of Pygame. fixed and running well now – MoulPredator Jul 30 '22 at 05:59

0 Answers0