当前位置: 首页>>代码示例>>Python>>正文


Python mpv.MPV属性代码示例

本文整理汇总了Python中mpv.MPV属性的典型用法代码示例。如果您正苦于以下问题:Python mpv.MPV属性的具体用法?Python mpv.MPV怎么用?Python mpv.MPV使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在mpv的用法示例。


在下文中一共展示了mpv.MPV属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_register_decorator_fun_chaining

# 需要导入模块: import mpv [as 别名]
# 或者: from mpv import MPV [as 别名]
def test_register_decorator_fun_chaining(self):
        b = mpv.MPV._binding_name

        @self.m.key_binding('a')
        @self.m.key_binding('b')
        def reg_test_fun(state, name, char):
            pass

        @self.m.key_binding('c')
        def reg_test_fun_2_stay_intact(state, name, char):
            pass

        self.assertEqual(reg_test_fun.mpv_key_bindings, ['b', 'a'])
        self.assertIn(b('a'), self.m._key_binding_handlers)
        self.assertIn(b('b'), self.m._key_binding_handlers)
        self.assertIn(b('c'), self.m._key_binding_handlers)
        self.assertEqual(self.m._key_binding_handlers[b('a')], reg_test_fun)
        self.assertEqual(self.m._key_binding_handlers[b('b')], reg_test_fun)

        reg_test_fun.unregister_mpv_key_bindings()
        self.assertNotIn(b('a'), self.m._key_binding_handlers)
        self.assertNotIn(b('b'), self.m._key_binding_handlers)
        self.assertIn(b('c'), self.m._key_binding_handlers) 
开发者ID:jaseg,项目名称:python-mpv,代码行数:25,代码来源:mpv-test.py

示例2: __init__

# 需要导入模块: import mpv [as 别名]
# 或者: from mpv import MPV [as 别名]
def __init__(self, args=None, *argv, **kwargs):
        """
        Create the MPV wrapper.

        :param args: Default arguments that will be passed to the mpv executable
            as a key-value dict (names without the `--` prefix). See `man mpv`
            for available options.
        :type args: dict[str, str]
        """

        super().__init__(*argv, **kwargs)

        self.args = self._default_mpv_args
        if args:
            # noinspection PyTypeChecker
            self.args.update(args)

        self._player = None
        self._playback_rebounce_event = threading.Event()
        self._on_stop_callbacks = [] 
开发者ID:BlackLight,项目名称:platypush,代码行数:22,代码来源:mpv.py

示例3: setUp

# 需要导入模块: import mpv [as 别名]
# 或者: from mpv import MPV [as 别名]
def setUp(self):
        self.disp = Xvfb()
        self.disp.start()
        self.m = mpv.MPV(vo='x11') 
开发者ID:jaseg,项目名称:python-mpv,代码行数:6,代码来源:mpv-test.py

示例4: test_register_direct_fun

# 需要导入模块: import mpv [as 别名]
# 或者: from mpv import MPV [as 别名]
def test_register_direct_fun(self):
        b = mpv.MPV._binding_name

        def reg_test_fun(state, name, char):
            pass

        self.m.register_key_binding('a', reg_test_fun)
        self.assertIn(b('a'), self.m._key_binding_handlers)
        self.assertEqual(self.m._key_binding_handlers[b('a')], reg_test_fun)

        self.m.unregister_key_binding('a')
        self.assertNotIn(b('a'), self.m._key_binding_handlers) 
开发者ID:jaseg,项目名称:python-mpv,代码行数:14,代码来源:mpv-test.py

示例5: test_register_direct_bound_method

# 需要导入模块: import mpv [as 别名]
# 或者: from mpv import MPV [as 别名]
def test_register_direct_bound_method(self):
        b = mpv.MPV._binding_name

        class RegTestCls:
            def method(self, state, name, char):
                pass
        instance = RegTestCls()

        self.m.register_key_binding('a', instance.method)
        self.assertIn(b('a'), self.m._key_binding_handlers)
        self.assertEqual(self.m._key_binding_handlers[b('a')], instance.method)

        self.m.unregister_key_binding('a')
        self.assertNotIn(b('a'), self.m._key_binding_handlers) 
开发者ID:jaseg,项目名称:python-mpv,代码行数:16,代码来源:mpv-test.py

示例6: test_register_decorator_fun

# 需要导入模块: import mpv [as 别名]
# 或者: from mpv import MPV [as 别名]
def test_register_decorator_fun(self):
        b = mpv.MPV._binding_name

        @self.m.key_binding('a')
        def reg_test_fun(state, name, char):
            pass
        self.assertEqual(reg_test_fun.mpv_key_bindings, ['a'])
        self.assertIn(b('a'), self.m._key_binding_handlers)
        self.assertEqual(self.m._key_binding_handlers[b('a')], reg_test_fun)

        reg_test_fun.unregister_mpv_key_bindings()
        self.assertNotIn(b('a'), self.m._key_binding_handlers) 
开发者ID:jaseg,项目名称:python-mpv,代码行数:14,代码来源:mpv-test.py

示例7: test_custom_stream

# 需要导入模块: import mpv [as 别名]
# 或者: from mpv import MPV [as 别名]
def test_custom_stream(self):
        handler = mock.Mock()
        fail_mock = mock.Mock(side_effect=ValueError)
        stream_mock = mock.Mock()
        stream_mock.seek = mock.Mock(return_value=0)
        stream_mock.read = mock.Mock(return_value=b'')

        disp = Xvfb()
        disp.start()
        m = mpv.MPV(video=False)
        m.register_event_callback(handler)

        m.register_stream_protocol('pythonfail', fail_mock)

        @m.register_stream_protocol('pythonsuccess')
        def open_fn(uri):
            self.assertEqual(uri, 'pythonsuccess://foo')
            return stream_mock

        m.play('pythondoesnotexist://foo')
        m.wait_for_playback()
        handler.assert_any_call({'reply_userdata': 0, 'error': 0, 'event_id': mpv.MpvEventID.END_FILE, 'event': {'reason': mpv.MpvEventEndFile.ERROR, 'error': mpv.ErrorCode.LOADING_FAILED}})
        handler.reset_mock()

        m.play('pythonfail://foo')
        m.wait_for_playback()
        handler.assert_any_call({'reply_userdata': 0, 'error': 0, 'event_id': mpv.MpvEventID.END_FILE, 'event': {'reason': mpv.MpvEventEndFile.ERROR, 'error': mpv.ErrorCode.LOADING_FAILED}})
        handler.reset_mock()

        m.play('pythonsuccess://foo')
        m.wait_for_playback()
        stream_mock.seek.assert_any_call(0)
        stream_mock.read.assert_called()
        handler.assert_any_call({'reply_userdata': 0, 'error': 0, 'event_id': mpv.MpvEventID.END_FILE, 'event': {'reason': mpv.MpvEventEndFile.ERROR, 'error': mpv.ErrorCode.UNKNOWN_FORMAT}})

        m.terminate()
        disp.stop() 
开发者ID:jaseg,项目名称:python-mpv,代码行数:39,代码来源:mpv-test.py

示例8: test_create_destroy

# 需要导入模块: import mpv [as 别名]
# 或者: from mpv import MPV [as 别名]
def test_create_destroy(self):
        thread_names = lambda: [ t.name for t in threading.enumerate() ]
        self.assertNotIn('MPVEventHandlerThread', thread_names())
        m = mpv.MPV()
        self.assertIn('MPVEventHandlerThread', thread_names())
        m.terminate()
        self.assertNotIn('MPVEventHandlerThread', thread_names()) 
开发者ID:jaseg,项目名称:python-mpv,代码行数:9,代码来源:mpv-test.py

示例9: test_flags

# 需要导入模块: import mpv [as 别名]
# 或者: from mpv import MPV [as 别名]
def test_flags(self):
        with self.assertRaises(AttributeError):
            mpv.MPV('this-option-does-not-exist')
        m = mpv.MPV('cursor-autohide-fs-only', 'fs', video=False)
        self.assertTrue(m.fullscreen)
        self.assertEqual(m.cursor_autohide, 1000)
        m.terminate() 
开发者ID:jaseg,项目名称:python-mpv,代码行数:9,代码来源:mpv-test.py

示例10: test_options

# 需要导入模块: import mpv [as 别名]
# 或者: from mpv import MPV [as 别名]
def test_options(self):
        with self.assertRaises(AttributeError):
            mpv.MPV(this_option_does_not_exists=23)
        m = mpv.MPV(osd_level=0, loop='inf', deinterlace=False)
        self.assertEqual(m.osd_level, 0)
        self.assertEqual(m.loop, True)
        self.assertEqual(m.deinterlace, False)
        m.terminate() 
开发者ID:jaseg,项目名称:python-mpv,代码行数:10,代码来源:mpv-test.py

示例11: test_log_handler

# 需要导入模块: import mpv [as 别名]
# 或者: from mpv import MPV [as 别名]
def test_log_handler(self):
        handler = mock.Mock()
        m = mpv.MPV(video=False, log_handler=handler)
        m.play(TESTVID)
        m.wait_for_playback()
        m.terminate()
        for call in handler.mock_calls:
            _1, (a, b, c), _2 = call
            if a == 'info' and b == 'cplayer' and c.startswith('Playing: '):
                break
        else:
            self.fail('"Playing: foo..." call not found in log handler calls: '+','.join(repr(call) for call in handler.mock_calls)) 
开发者ID:jaseg,项目名称:python-mpv,代码行数:14,代码来源:mpv-test.py

示例12: __init__

# 需要导入模块: import mpv [as 别名]
# 或者: from mpv import MPV [as 别名]
def __init__(self, *args, **kwargs):
    Gtk.Box.__init__(self, *args, **kwargs)

    self.vid_url = None
    self.stopped = False

    self.canvas = Gtk.DrawingArea()
    self.pack_start(self.canvas, True, True, 0)

    self.player = mpv.MPV(ytdl=True, input_cursor=False, cursor_autohide=False)
    self.canvas.connect('realize', self.on_canvas_realize)
    self.canvas.connect('draw', self.on_canvas_draw)

    add_widget_class(self, 'player-video') 
开发者ID:jonian,项目名称:kickoff-player,代码行数:16,代码来源:mpvbox.py

示例13: _init_mpv

# 需要导入模块: import mpv [as 别名]
# 或者: from mpv import MPV [as 别名]
def _init_mpv(self, args=None):
        import mpv

        mpv_args = self.args.copy()
        if args:
            mpv_args.update(args)

        for k, v in self._env.items():
            os.environ[k] = v

        self._player = mpv.MPV(**mpv_args)
        # noinspection PyProtectedMember
        self._player._event_callbacks += [self._event_callback()] 
开发者ID:BlackLight,项目名称:platypush,代码行数:15,代码来源:mpv.py

示例14: __init__

# 需要导入模块: import mpv [as 别名]
# 或者: from mpv import MPV [as 别名]
def __init__(self):
        #URL of list
        self.url = ""
        #Player volume
        self.volume = 70
        #Set unlock on continous_player
        self._lock = False
        #Semaphore for the shared _lock variable
        self._lock_mutex = threading.Semaphore()
        #Open the paylists dict from pickle here
        self.saved_lists = []
        #Currently playing song name
        self._currentSong = "None"
        ##Current song index
        self.index = 0
        ##New playlist?
        self._new = True
        #Define queue length
        self.queue_len = 0
        #Define repeat mode 1:Repeat off | 2:Repeat current song | 3:Repeat list.
        #Default mode is 1
        self.repeat_mode = 1
        #Define random 0:Random off | 1:Random on
        self.random = 0
        #This lock is for locking in case music is paused intentionlly
        self._togglerLock = False
        #Semaphore for the shared _togglerLock variable
        self._togglerLock_mutex = threading.Semaphore()
        #Make time details dict
        self.time_details = {}
        #Random on or off?
        self._random = False
        # This is changed to true by the continous player and then back to
        # false by an event handler
        self._song_changed = False
        self.path = os.path.split(os.path.abspath(__file__))[0]
        for every_file in os.listdir(PL_DIR):
            self.saved_lists.append(every_file)
        #Initialize MPV player
        locale.setlocale(locale.LC_NUMERIC, "C")
        self.player = None 
开发者ID:TimeTraveller-San,项目名称:yTermPlayer,代码行数:43,代码来源:music_api.py

示例15: start_playing

# 需要导入模块: import mpv [as 别名]
# 或者: from mpv import MPV [as 别名]
def start_playing(self):
        if not self.player:
            self.player = mpv.MPV(video=False)
        thread = threading.Thread(target = self.continous_player, args={})
        thread.daemon = True
        thread.start() 
开发者ID:TimeTraveller-San,项目名称:yTermPlayer,代码行数:8,代码来源:music_api.py


注:本文中的mpv.MPV属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。