Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Playing mp3 with pyglet
#1
Hi

I use pyglet to play songs in wav and mp3 formats. According to docs of Pyglet, I should install ffmpeg, so I did it but problem is:


p = pyglet.media.Player()
file = pyglet.media.load(r'C:\Zeta.mp3')

TraceBack (most recent call last):

...

  File "C:\Python3\lib\site-packages\pyglet\media\codecs\wave.py", line 59, in __init__
    raise WAVEDecodeException(e)
pyglet.media.codecs.wave.WAVEDecodeException: file does not start with RIFF id
What is wrong? Probably, I installed ffmpeg in wrong way? What I do: install windows built from here: https://www.ffmpeg.org/ and then copy files into folder 'ffmpeg' in C:\ , after it I set a path in environment variables. How to check whether I installed ffmpeg correctly?

To be presice:

Windows 10 64x

>>> pyglet.version
'2.0.dev0'
Reply
#2
I see the have changed since i last looked from AVbin to FFmpeg.
They could done a better job with integrate FFmpeg.

You need to download the shared builds,if will fail with the noraml binary download.
Now is same folder as you run code make a folder lib and extract files from link over to it.
Output:
E:div_code\pyglet_test\ |-- play_test.py lib\ |-- files from .zip
# play_test.py
import pyglet

pyglet.options['search_local_libs'] = True
media = pyglet.media.load('song.mp3')
media.play()

# Ctrl+c to quit
try:
    while True:
        pyglet.app.run()
except KeyboardInterrupt:
    pass
This load the files from lib folder
pyglet.options['search_local_libs'] = True
Reply
#3
(Jan-11-2020, 07:38 PM)snippsat Wrote: I see the have changed since i last looked from AVbin to FFmpeg.
They could done a better job with integrate FFmpeg.

You need to download the shared builds,if will fail with the noraml binary download.
Now is same folder as you run code make a folder lib and extract files from link over to it.
Output:
E:div_code\pyglet_test\ |-- play_test.py lib\ |-- files from .zip
# play_test.py
import pyglet

pyglet.options['search_local_libs'] = True
media = pyglet.media.load('song.mp3')
media.play()

# Ctrl+c to quit
try:
    while True:
        pyglet.app.run()
except KeyboardInterrupt:
    pass
This load the files from lib folder
pyglet.options['search_local_libs'] = True

Thank you! It seems to me that you had some experience with Pyglet, can you tell me how I can receive the name of current playing media-source?

To be clear:

I am working on audio player in Python with Pyglet.

Pyglet supports such functions as

source = pyglet.media.load(self.playlist[i])
pyglet.media.Player.queue(source)
pyglet.media.Player.play()
pyglet.media.Player.next_source()
that allow me to load audio files, to queue and to play them and also switch to the next audio file. It's fine. But also I want to switch to the previous audio file. How I can do it?

There is no built-in function! I think about tracing the name of current audio file, but how I can receive a kind of signal from Pyglet that the next audio file in queue has been started?

Probably, there are another solutions?
Reply
#4
Hi! Could you show me the result of your work if you finish it? You worked on the audio player with Pyglet, right? I don't have much experience in python, unfortunately, but I'm interested in this topic and would like to figure it out. I'm a real musician, and I have a lot of different music, but I don't have a proper audio player that I'm comfortable using. I download mp3 free on various sites, and there are a lot of them now. And like I said, I would like to work on an audio player too. Thanks in advance for your help!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  pyglet problem deansenecal 1 1,902 Feb-15-2021, 11:15 PM
Last Post: Larz60+
  How many times was the button pressed in pyglet rama27 0 1,888 Oct-10-2020, 10:26 AM
Last Post: rama27
  Pyglet installation problems LostinPy 3 5,495 Feb-07-2018, 08:47 PM
Last Post: LostinPy
  Game in Pycharm using pyglet pierrem13 0 3,167 Nov-29-2017, 01:54 AM
Last Post: pierrem13
  Pyglet Media: unjustifiable memory usage hbknjr 4 4,522 Aug-20-2017, 02:08 AM
Last Post: hbknjr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020