當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。