E
E
Emil Sagatdinov2017-01-09 17:20:37
Python
Emil Sagatdinov, 2017-01-09 17:20:37

How to play .mp3 file in Python using PyGame and PyGlet?

Hello, I need help, I'm trying to write an alarm clock with a timer, I ran into one problem, namely, trying to play an mp3 file. You need to use PyGame or PyGlet. when I try to run the program, it gives an error, I will throw off the code and text of the error at the end, could you explain to me how to play .mp3 files, I will be very grateful.
Code:
import pyglet
song = pyglet.media.load('D:\Emil\Python\timer\zvuki-zvonok_budilnika.mp3')
song.play()
pyglet.app.run()
Error:
Traceback (most recent call last) :
File "D:/Emil/Python/timer/timer.py", line 3, in
song = pyglet.media.load('D:\Emil\Python\timer\zvuki-zvonok_budilnika.mp3')
File "C:\Python32\lib\site-packages\pyglet\media\__init__.py", line 1429, in load
source = get_source_loader().load(filename, file)
File "C:\Python32\lib\site- packages\pyglet\media\__init__.py", line 1410, in load
return riff.WaveSource(filename, file)
File "C:\Python32\lib\site-packages\pyglet\media\riff.py", line 185, in __init__
file = open(filename, 'rb')
IOError: [Errno 22] Invalid argument: 'D:\\Emil\\Python\timer\\zvuki-zvonok_budilnika.mp3
' who only learn to program.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WalletDat, 2017-01-09
@emilka174

import pyglet
song = pyglet.media.load('D:\\Эмиль\\Python\\timer\\zvuki-zvonok_budilnika.mp3')
song.play()
pyglet.app.run()

#либо pyglet.media.load(r'D:\Эмиль\Python\timer\zvuki-zvonok_budilnika.mp3')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question