'Issues with pygame and libmpg123-0.dll

import pygame

pygame.mixer.init()
pygame.mixer.music.load("water.mp3")
pygame.mixer.music.set_volume(0.7)
pygame.mixer.music.play()
while True:

    print("Press 'p' to pause, 'r' to resume")
    print("Press 'e' to exit the program")
    query = input("  ")

    if query == 'p':
        pygame.mixer.music.pause()
        
    elif query == 'r':
        pygame.mixer.music.unpause()
        
    elif query == 'e':
        pygame.mixer.music.stop()
        break

I wrote this but error showing this

Traceback (most recent call last): File "C:\Python Programming\play_sound.py", line 7, in pygame.mixer.music.load("water.mp3") pygame.error: Failed loading libmpg123-0.dll: The specified module could not be found.



Solution 1:[1]

Your game is not responding, because you ask for an input inside the application loop. input stops the application loop and waits for input to be confirmed. If you stop the application loop, the window stops responding. Use the KEYDOWN event to get an input in PyGame (see pygame.event):

while True:

    query  = None
    for event in pygame.event.get():
        if event.type == pygame.KEYDOWN:
            query = event.unicode

    # [...]

Solution 2:[2]

There are 4 options you can try all of them and can see which ones work for you

1.Restart your IDE if that doesn't work try restarting your PC.

2.uninstalled and reinstalled the "pygame" library from this site. https://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame. which worked well.

3. Step 1: Go to browser and search download libmpg123.dll.

Step 2: download libmpg123.dll and Extract it.

Step 3: After Extract (cut or copy) the two docs and paste in "C:\Windows\System32".

Step 4: Installation is successfully done.

  1. Or you can convert your mp3 file to a WAV file and then use it.

Solution 3:[3]

Download libmpg123-0.dll from google or search for it in your AppData. Now copy the file into your C:/Windows/System32 folder.

It should work!!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rabbid76
Solution 2 NEELANGSHU NATH
Solution 3 Amresh