Пример #1
0
    def __init__(self, parent, file=None, source=None, playing=False,
                 x=0, y=0, z=0, width=None, height=None, scale=True, **kw):
        self.parent = parent
        self.scale = scale

        if file is not None:
            source = self.source = media.load(file, streaming=True)
        else:
            assert source is not None, 'one of file or source is required'

        self.player = media.Player()
        self.player.eos_action = self.player.EOS_PAUSE
        self.player.on_eos = self.on_eos

        # poke at the video format
        if not source.video_format:
            raise ValueError("Movie file doesn't contain video")
        video_format = source.video_format
        if width is None:
            width = video_format.width
            if video_format.sample_aspect > 1:
                width *= video_format.sample_aspect
        if height is None:
            height = video_format.height
            if video_format.sample_aspect < 1:
                height /= video_format.sample_aspect

        super().__init__(parent, x, y, z, width, height, **kw)

        # control frame top-level
        c = self.control = Frame(self, bgcolor=(1, 1, 1, .5),
                                 is_visible=False, width='100%', height=64)

        # controls underlay
        f = Frame(c, is_transparent=True, width='100%', height='100%')
        f.layout = layouts.Horizontal(f, valign='center', halign='center',
                                      padding=10)
        c.play = Image(f, data.load_gui_image('media-play.png'),
                       classes=('-play-button',), is_visible=not playing)
        c.pause = Image(f, data.load_gui_image('media-pause.png'),
                        bgcolor=None, classes=('-pause-button',),
                        is_visible=playing)
        fi = Frame(f, is_transparent=True)
        c.range = Image(fi, data.load_gui_image('media-range.png'))
        im = data.load_gui_image('media-position.png')
        c.position = Image(fi, im, x=0, y=-2, classes=('-position',))
        c.time = Label(f, '00:00', font_size=20)
        c.anim = None

        # make sure we get at least one frame to display
        self.player.queue(source)
        clock.schedule(self.update)
        self.playing = False
        if playing:
            self.play()
Пример #2
0
    def __init__(self, parent, file=None, source=None, title=None,
                 playing=False, bgcolor=(1, 1, 1, 1), color=(0, 0, 0, 1),
                 font_size=20, **kw):
        """Pass in a filename as "file" or a pyglet Source as "source".
        """
        self.parent = parent

        if file is not None:
            source = media.load(file, streaming=True)
        else:
            assert source is not None, 'one of file or source is required'

        self.player = media.Player()

        # poke at the audio format
        if not source.audio_format:
            raise ValueError("File doesn't contain audio")

        super().__init__(parent, bgcolor=bgcolor, **kw)

        # lay it out

        # control frame top-level
        c = self.control = Frame(self, width='100%', height=64)

        ft = Frame(c, is_transparent=True, width='100%', height='100%')
        ft.layout = layouts.Vertical(ft)
        Label(ft, title or 'unknown', color=color, bgcolor=bgcolor,
              padding=2, font_size=font_size)

        # controls underlay
        f = Frame(ft, is_transparent=True, width='100%', height='100%')
        f.layout = layouts.Horizontal(f, valign='center', halign='center',
                                      padding=10)
        c.play = Image(f, data.load_gui_image('media-play.png'),
                       classes=('-play-button',), is_visible=not playing)
        c.pause = Image(f, data.load_gui_image('media-pause.png'),
                        bgcolor=None, classes=('-pause-button',),
                        is_visible=playing)
        fi = Frame(f, is_transparent=True)
        c.range = Image(fi, data.load_gui_image('media-range.png'))
        c.position = Image(fi, data.load_gui_image('media-position.png'),
                           y=-2, classes=('-position',))
        c.time = Label(f, '00:00', font_size=20)
        c.anim = None

        # make sure we get at least one frame to display
        self.player.queue(source)
        clock.schedule(self.update)
        self.playing = False
        if playing:
            self.play()
Пример #3
0
    def __init__(self, parent, file=None, source=None, title=None,
            playing=False, bgcolor=(1, 1, 1, 1), color=(0, 0, 0, 1),
            font_size=20, **kw):
        '''Pass in a filename as "file" or a pyglet Source as "source".
        '''
        self.parent = parent

        if file is not None:
            source = media.load(file, streaming=True)
        else:
            assert source is not None, 'one of file or source is required'

        self.player = media.Player()

        # poke at the audio format
        if not source.audio_format:
            raise ValueError("File doesn't contain audio")

        super(Music, self).__init__(parent, bgcolor=bgcolor, **kw)

        # lay it out

        # control frame top-level
        c = self.control = Frame(self, width='100%', height=64)

        ft = Frame(c, is_transparent=True, width='100%', height='100%')
        ft.layout = layouts.Vertical(ft)
        Label(ft, title or 'unknown', color=color, bgcolor=bgcolor,
            padding=2, font_size=font_size)

        # controls underlay
        f = Frame(ft, is_transparent=True, width='100%', height='100%')
        f.layout = layouts.Horizontal(f, valign='center', halign='center',
            padding=10)
        c.play = Image(f, data.load_gui_image('media-play.png'),
            classes=('-play-button',), is_visible=not playing)
        c.pause = Image(f, data.load_gui_image('media-pause.png'),
            bgcolor=None, classes=('-pause-button',), is_visible=playing)
        fi = Frame(f, is_transparent=True)
        c.range = Image(fi, data.load_gui_image('media-range.png'))
        c.position = Image(fi, data.load_gui_image('media-position.png'),
            y=-2, classes=('-position',))
        c.time = Label(f, '00:00', font_size=20)
        c.anim = None

        # make sure we get at least one frame to display
        self.player.queue(source)
        clock.schedule(self.update)
        self.playing = False
        if playing:
            self.play()
Пример #4
0
    def __init__(self,
                 parent,
                 file=None,
                 source=None,
                 playing=False,
                 x=0,
                 y=0,
                 z=0,
                 width=None,
                 height=None,
                 scale=True,
                 **kw):
        self.parent = parent
        self.scale = scale

        if file is not None:
            source = self.source = media.load(file, streaming=True)
        else:
            assert source is not None, 'one of file or source is required'

        self.player = media.Player()
        self.player.eos_action = self.player.EOS_PAUSE
        self.player.on_eos = self.on_eos

        # poke at the video format
        if not source.video_format:
            raise ValueError("Movie file doesn't contain video")
        video_format = source.video_format
        if width is None:
            width = video_format.width
            if video_format.sample_aspect > 1:
                width *= video_format.sample_aspect
        if height is None:
            height = video_format.height
            if video_format.sample_aspect < 1:
                height /= video_format.sample_aspect

        super().__init__(parent, x, y, z, width, height, **kw)

        # control frame top-level
        c = self.control = Frame(self,
                                 bgcolor=(1, 1, 1, .5),
                                 is_visible=False,
                                 width='100%',
                                 height=64)

        # controls underlay
        f = Frame(c, is_transparent=True, width='100%', height='100%')
        f.layout = layouts.Horizontal(f,
                                      valign='center',
                                      halign='center',
                                      padding=10)
        c.play = Image(f,
                       data.load_gui_image('media-play.png'),
                       classes=('-play-button', ),
                       is_visible=not playing)
        c.pause = Image(f,
                        data.load_gui_image('media-pause.png'),
                        bgcolor=None,
                        classes=('-pause-button', ),
                        is_visible=playing)
        fi = Frame(f, is_transparent=True)
        c.range = Image(fi, data.load_gui_image('media-range.png'))
        im = data.load_gui_image('media-position.png')
        c.position = Image(fi, im, x=0, y=-2, classes=('-position', ))
        c.time = Label(f, '00:00', font_size=20)
        c.anim = None

        # make sure we get at least one frame to display
        self.player.queue(source)
        clock.schedule(self.update)
        self.playing = False
        if playing:
            self.play()
 def get_arrow(cls):
     if not hasattr(cls, 'image_object'):
         cls.image_object = data.load_gui_image('slider-arrow-down.png')
     return cls.image_object
Пример #6
0
 def get_arrow(cls):
     if not hasattr(cls, 'image_object'):
         cls.image_object = data.load_gui_image(cls.image_file)
     return cls.image_object
Пример #7
0
 def get_arrow(cls):
     if not hasattr(cls, 'image_object'):
         cls.image_object = data.load_gui_image('slider-arrow-down.png')
     return cls.image_object
Пример #8
0
 def get_arrow(cls):
     if not hasattr(cls, 'image_object'):
         cls.image_object = data.load_gui_image(cls.image_file)
     return cls.image_object