Search code examples
pythonexceptionpyglet

Python error when playing music with Pyglet: UserWarning: exception: access violation reading 0x00000014


I tried several iterations of this code using methods, schedules and others. I managed to get over "access violation writing error" but "access violation reading error" is still present no matter what I try. Here is the code:

import pyglet

window = pyglet.window.Window()
window.set_caption('First Pyglet Experiment')

player = pyglet.media.Player()
player.queue(pyglet.resource.media('test song.mp3'))
player.loop = True

@window.event
def on_close():
    player.delete()

player.play()  
pyglet.app.run()  

After the first interaction of my song is done, it raises over and over this error:

D:\_Programming_\Python\venv\lib\site-packages\pyglet\media\codecs\wmf.py:771: UserWarning: exception: access violation reading 0x00000014
  warnings.warn(e)

I would appreciate any advice. Thanks in advance.


Solution

  • I am a code contributor to Pyglet and I wrote the codec that's causing the issue. This is a bug and it should be fixed in the next pyglet release (1.5.6).

    I recently added Windows Media Foundation support. It allows simple formats like mp3 to be decoded without having to install third party libraries like ffmpeg (otherwise only wav is supported). I was able to replicate this bug with the help of another individual that had this issue. I narrowed it down to affecting just 32 bit python users, but it was a mistake on my part.

    The reason it works for wave is because you're actually picking a different decoder. The decoder with the issue should be fixed in the next release. Sorry about the trouble.