コード例 #1
0
ファイル: test_commands.py プロジェクト: ysilvela/mopidy
 def test_integer(self):
     self.assertEqual(123, protocol.INT('123'))
     self.assertEqual(-123, protocol.INT('-123'))
     self.assertEqual(123, protocol.INT('+123'))
     self.assertRaises(ValueError, protocol.INT, '3.14')
     self.assertRaises(ValueError, protocol.INT, '')
     self.assertRaises(ValueError, protocol.INT, 'abc')
     self.assertRaises(ValueError, protocol.INT, '12 34')
コード例 #2
0
def seekcur(context, time):
    """
    *musicpd.org, playback section:*

        ``seekcur {TIME}``

        Seeks to the position ``TIME`` within the current song. If prefixed by
        '+' or '-', then the time is relative to the current playing position.
    """
    if time.startswith(('+', '-')):
        position = context.core.playback.time_position.get()
        position += protocol.INT(time) * 1000
        context.core.playback.seek(position).get()
    else:
        position = protocol.UINT(time) * 1000
        context.core.playback.seek(position).get()