So im making a python game with python and I'm using mixer to play audio, but when I run the game this error shows
pygame 2.1.2 (SDL 2.0.16, Python 3.8.12)
Hello from the pygame community. https://www.pygame.org/contribute.html
music started playing....
Traceback (most recent call last):
File "main.py", line 22, in <module>
mixer.music.play('walk the dinosaur.mp3')
TypeError: an integer is required (got type str)"
this is my code
import pyflakes
import pygame
import os
from pygame import mixer
pygame.init()
loc = 1
input
wtd = 'walk the dinosaur.mp3'
mixer.init()
#Load audio file
mixer.music.load('walk the dinosaur.mp3')
print("music started playing....")
#Set preferred volume
mixer.music.set_volume(0.2)
#Play the music
mixer.music.play('walk the dinosaur.mp3')
According to pygame's documentation (https://www.pygame.org/docs/ref/music.html#pygame.mixer.music.play),
the
playfunction doesn't have any required parameters. Unless you want to change any of the default ones (loops, start, or fade_ms) you don't need to pass anything to it.