-2

error:

  Traceback (most recent call last):
  File "src\\gevent\\greenlet.py", line 854, in gevent._gevent_cgreenlet.Greenlet.run
  File "eel\__init__.py", line 259, in _process_message
  File "main.py", line 40, in play_music
pygame.error: Failed loading libmpg123-0.dll: The specified module could not be found.

2020-08-28T18:46:27Z <Greenlet at 0x4b29138: _process_message({'call': 1.305899873486772, 'name': 'play_music', , <geventwebsocket.websocket.WebSocket object at 0x0)> failed with error

pyinstaller command:

python -m eel main.py web --console --onefile --icon=ico.ico

mp3 files don't play but wav files works...

  • You could just go on a conversion website https://audio.online-convert.com/convert-to-wav and convert the MP3 file to WAV – NoName69 Aug 28 '20 at 21:09

1 Answers1

0

Try the following snippet:

import pygame
mp3_file = 'song.mp3'
pygame.init()
pygame.mixer.init()
clock = pygame.time.Clock()
pygame.mixer.music.load(mp3_file)
pygame.mixer.music.play()
while pygame.mixer.music.get_busy():
    clock.tick(10)

This should play the music and run the rest of the game.

You are able to do the following as well:

import pygame
mp3_file = 'song.mp3'
pygame.init()
pygame.mixer.init()
pygame.mixer.music.load(mp3_file)
pygame.mixer.music.play()
pygame.event.wait()

But the game will stop executing and wait for the mp3 to finish. This is because of pygame.event.wait()

There are many examples here: Play MP3 in pygame

lime
  • 801
  • 8
  • 21