Esempio n. 1
0
    def set_speed(self, args):
        """Change playback speed

        Arguments:
        speed -- speed or increment
        mode  -- how to change speed (relative by default or set)
        """
        speed = args[0] if len(args) == 1 else 1
        mode = args[1] if len(args) == 2 else ''

        try:
            speed = round(float(speed), 1)
        except ValueError:
            error(self._nvim, 'argument should be a number')
            return

        if mode == 'set':
            self._player.speed = speed
        else:
            if (self._player.speed + speed) >= 0.1:
                self._player.speed += speed
            else:
                error(self._nvim, 'speed is already at minimum setting')
                return

        info = 'playback speed set to {:1.1f}'.format(self._player.speed)
        msg(self._nvim, info)
Esempio n. 2
0
    def msg_progress(self, args):
        """Display message with position in current file"""

        # Wait for media file to be properly loaded
        self._player.wait_for_property('time-pos')

        time_pos = fmtseconds(self._player.time_pos)
        perc_pos = round(self._player.percent_pos)

        msg_time_pos = 'progress: {} ({}%)'.format(time_pos, perc_pos)
        msg(self._nvim, msg_time_pos)
Esempio n. 3
0
        def echo_seek(event):
            seek = self._last_seek
            time_pos = fmtseconds(self._player.time_pos)

            if seek == 0:
                seek_msg = 'jump to {}'.format(time_pos)
            else:
                direction = 'forward' if seek > 0 else 'backward'
                seek_msg = 'seek {} ({:+d}s): {}'.format(direction,
                                                         seek, time_pos)

            msg(self._nvim, seek_msg)
            self._last_seek = 0
Esempio n. 4
0
    def set_timepos(self, args):
        """Set time position in current media file"""

        # Wait for media file to be properly loaded
        self._player.wait_for_property('time-pos')

        if not args:
            error(self._nvim, 'takes at least one argument')
            return

        time = args[0]
        fmt = args[1] if len(args) == 2 else '%H:%M:%S'
        msg(self._nvim, fmt)

        try:
            seconds = time_to_seconds(time, fmt)
        except ValueError:
            error(self._nvim, 'argument should be formatted as %H:%M:%S')
            return

        self._player.time_pos = seconds
Esempio n. 5
0
 def echo_unpause(event):
     msg(self._nvim, 'playback resumed')
Esempio n. 6
0
 def echo_pause(event):
     msg(self._nvim, 'playback paused')
Esempio n. 7
0
 def echo_loaded(event):
     msg(self._nvim, 'media loaded')