如何使用Python cocos2d播放AVI或MPEG视频

2024-10-02 22:29:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在为python使用cocos2d游戏引擎。我读了api文档,但找不到视频库。如何用pythoncos2d播放avi或mpeg视频?在


Tags: 文档引擎api游戏视频cocos2dmpegavi
1条回答
网友
1楼 · 发布于 2024-10-02 22:29:26

我找到了这个解决方案。在

class VideoLayer (Layer):
    def __init__(self, video_name):
        super(VideoLayer, self).__init__()

        source = pyglet.media.load(video_name)
        format = source.video_format
        if not format:
            print 'No video track in this source.'
            return

        self.media_player = pyglet.media.Player()
        self.media_player.queue(source)
        self.media_player.play()

    def draw(self):
        self.media_player.get_texture().blit(0, 0)

相关问题 更多 >