The IDAJ Show
The IDAJ Show

Reputation: 65

Getting Error When I Try And Play A Sound In Pygame

I am getting an error when I try and play a sound in pygame. This is my code

import pygame
pygame.init()


pygame.mixer.music.load('easy going.mp3')
pygame.mixer.music.play(0)

And this is the error it gives me

File "c:/Users/Isaiah/Desktop/All of my programs/pygame sound.py", line 5, in pygame.mixer.music.load('easy going.mp3') pygame.error: Couldn't open 'easy going.mp3'

Upvotes: 0

Views: 530

Answers (1)

The IDAJ Show
The IDAJ Show

Reputation: 65

I figured it out!

import pygame

pygame.mixer.init()

sound = pygame.mixer.Sound(r"C:\Users\Isaiah\Desktop\easy_going (online-audio-converter.com).wav")
s = pygame.mixer.Sound.play(sound)

#Delay loop
while s.get_busy():
    pygame.time.delay(100)

Upvotes: 1

Related Questions