简体   繁体   English

使用 Pyglet 播放音乐时出现 Python 错误:UserWarning:异常:访问冲突读取 0x00000014

[英]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.提前致谢。

Ok, so everything solved itself when I used.wav instead of.mp3.好的,所以当我使用.wav 而不是.mp3 时,一切都自行解决了。 It seems that pyglet supports mp3 but has some kind of internal problem with it. pyglet 似乎支持 mp3,但存在某种内部问题。 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.如果 window 突然关闭,这保证了文件的正确关闭。 "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.可能 Player() 需要安全关闭。

I am a code contributor to Pyglet and I wrote the codec that's causing the issue.我是 Pyglet 的代码贡献者,我编写了导致问题的编解码器。 This is a bug and it should be fixed in the next pyglet release (1.5.6).这是一个错误,应该在下一个 pyglet 版本(1.5.6)中修复。

I recently added Windows Media Foundation support.我最近添加了 Windows 媒体基础支持。 It allows simple formats like mp3 to be decoded without having to install third party libraries like ffmpeg (otherwise only wav is supported).它允许解码像 mp3 这样的简单格式,而无需安装像 ffmpeg 这样的第三方库(否则只支持 wav)。 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.我将其范围缩小到仅影响 32 位 python 用户,但这是我的错误。

The reason it works for wave is because you're actually picking a different decoder.它适用于 wave 的原因是因为您实际上选择了不同的解码器。 The decoder with the issue should be fixed in the next release.有问题的解码器应该在下一个版本中修复。 Sorry about the trouble.很抱歉给您带来麻烦。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Python中使用Pyglet和Tkinter播放音乐 - Playing music with Pyglet and Tkinter in Python Python:WindowsError:异常:访问冲突读取为0x00000000 - Python: WindowsError: exception: access violation reading 0x00000000 Python / Psychopy WindowsError:异常:读取访问冲突0x00000010 - Python/Psychopy WindowsError: exception: access violation reading 0x00000010 例外:从 Python 调用 C function 时读取访问冲突 - Exception: access violation reading when calling a C function from Python Python Ctypes异常:访问冲突读取 - Python Ctypes Exception: access violation reading Python调用DLL并调用Python,“ WindowsError:异常:访问冲突读取为0x00000004” - Python calling DLL calling Python, “WindowsError: exception: access violation reading 0x00000004” Ctypes:WindowsError:异常:调用C ++函数时访问冲突读取0x0000000000000400 - Ctypes: WindowsError: exception: access violation reading 0x0000000000000400 when calling C++ function PyOpenGL:glDrawArrays()-WindowsError:异常:访问冲突读取0x0000000000000000 - PyOpenGL: glDrawArrays() - WindowsError: exception: access violation reading 0x0000000000000000 ctypes: OSError: 异常:访问冲突读取 0x00000001 - ctypes: OSError: exception: access violation reading 0x00000001 自动单击异常:访问冲突读取0x00000083 - Auto it click exception: access violation reading 0x00000083
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM