如何使用python cocos2d播放avi或mpeg视频

时间:2011-07-13 14:38:17

标签: python cocos2d-python

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

1 个答案:

答案 0 :(得分:1)

我找到了这个解决方案。

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)