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

1

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.

python
exception
pyglet
asked on Stack Overflow Apr 27, 2020 by Teasin951

2 Answers

1

Ok, so everything solved itself when I used .wav instead of .mp3. It seems that pyglet supports mp3 but has some kind of internal problem with it. It could as well just be an incorrectly exported file.

You still need this part though:

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

this insured correct closing of the file if the window was suddenly closed. "access violation writing" error is still present without it.

For some reason this error is not present in this simple version:

import pyglet

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

music = pyglet.resource.media('background.wav')
music.play()

pyglet.app.run()

But causes problems in my more complex application. Probably the Player() needs to be turned off safely.

answered on Stack Overflow Apr 27, 2020 by Teasin951 • edited Apr 27, 2020 by Teasin951
1

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.

answered on Stack Overflow May 21, 2020 by Charlie • edited May 21, 2020 by Charlie

User contributions licensed under CC BY-SA 3.0