简体   繁体   中英

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.

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. 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. 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:

  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. I tried a different video player sample script for pyglet and get the same result. I tried looking up docs for pyglet 2.0 but could not find them.

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. Pyglet configuration in the issue link:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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