简体   繁体   English

如何在 pyglet 2.0 中播放视频?

[英]How to play videos in pyglet 2.0?

I'm writing a game using Python Arcade which requires pyglet-2.0dev9, and trying to play a video between levels of the game.我正在使用需要 pyglet-2.0dev9 的 Python Arcade 编写游戏,并尝试在游戏关卡之间播放视频。

To start simple, I tried running pyglet's sample media player ( https://github.com/pyglet/pyglet/blob/master/examples/media/media_player.py ) from the command line.首先,我尝试从命令行运行 pyglet 的示例媒体播放器( https://github.com/pyglet/pyglet/blob/master/examples/media/media_player.py )。 It works well with my mp4 video file when I have pyglet 1.5.21 installed, but it fails with pyglet 2.0-dev9 and dev11.当我安装了 pyglet 1.5.21 时,它适用于我的 mp4 视频文件,但适用于 pyglet 2.0-dev9 和 dev11 时它会失败。 I worked through one issue relating to displaying the GL video controls (I commented these out), but now I get this traceback when I run it:我解决了一个与显示 GL 视频控件相关的问题(我将这些注释掉了),但现在我在运行它时得到了这个回溯:

  File "/Users/bernard/projects/gralli_quest/media_player.py", line 369, in on_draw
    video_texture.blit(self.video_x,
  File "/Users/bernard/.pyenv/versions/gralliq/lib/python3.9/site-packages/pyglet/image/__init__.py", line 1424, in blit
    pyglet.graphics.draw_indexed(4, GL_TRIANGLES, [0, 1, 2, 0, 2, 3],
  File "/Users/bernard/.pyenv/versions/gralliq/lib/python3.9/site-packages/pyglet/graphics/__init__.py", line 262, in draw_indexed
    glDrawElements(mode, len(indices), index_type, index_array)
  File "/Users/bernard/.pyenv/versions/gralliq/lib/python3.9/site-packages/pyglet/gl/lib.py", line 114, in errcheck
    raise GLException('(0x%x): %s' % (error, msg))
pyglet.gl.lib.GLException: (0x502): Invalid operation. The specified operation is not allowed in the current state.

I compared the version of media_player.py in the pyglet repo under the dev7 tag with the one in master and it was the same.我将 pyglet repo 中 dev7 标签下的 media_player.py 版本与 master 中的版本进行了比较,结果是一样的。 I tried a different video player sample script for pyglet and get the same result.为 pyglet 尝试了不同的视频播放器示例脚本并得到了相同的结果。 I tried looking up docs for pyglet 2.0 but could not find them.我尝试查找 pyglet 2.0 的文档,但找不到它们。

Any help would be greatly appreciated!任何帮助将不胜感激!

-Bernard -伯纳德

Apparently this has been presented in other scenarios like this github.com/pyglet/pyglet/issues/138 , it is recommended that you run test examples and use python -m pyglet.info to check results of execution.显然,这已在github.com/pyglet/pyglet/issues/138等其他场景中出现,建议您运行test示例并使用python -m pyglet.info检查执行结果。 Pyglet configuration in the issue link:问题链接中的Pyglet配置:

pyglet.options['audio'] = ('directsound', 'openal', 'pulse', 'silent')
pyglet.options['debug_font'] = False
pyglet.options['debug_gl'] = True
pyglet.options['debug_gl_trace'] = False
pyglet.options['debug_gl_trace_args'] = False
pyglet.options['debug_gl_shaders'] = False
pyglet.options['debug_graphics_batch'] = False
pyglet.options['debug_lib'] = False
pyglet.options['debug_media'] = False
pyglet.options['debug_texture'] = False
pyglet.options['debug_trace'] = False
pyglet.options['debug_trace_args'] = False
pyglet.options['debug_trace_depth'] = 1
pyglet.options['debug_trace_flush'] = True
pyglet.options['debug_win32'] = False
pyglet.options['debug_x11'] = False
pyglet.options['shadow_window'] = True
pyglet.options['vsync'] = None
pyglet.options['xsync'] = True
pyglet.options['xlib_fullscreen_override_redirect'] = False
pyglet.options['search_local_libs'] = True

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM