bilibilivoice.mpv - mpv播放器使用

class bilibilivoice.mpv.MPV(*args, **kwargs)[源代码]

Bases: bilibilivoice.mpv.MPVBase

Class for communication with the mpv media player via unix socket based JSON IPC. It adds a few usable methods and a callback API.

To automatically register methods as event callbacks, subclass this class and define specially named methods as follows:

def on_file_loaded(self):
# This is called for every 'file-loaded' event. ...
def on_property_time_pos(self, position):
# This is called whenever the 'time-pos' property is updated. ...

Please note that callbacks are executed inside a separate thread. The MPV class itself is completely thread-safe. Requests from different threads to the same MPV instance are synchronized.

command(*args, timeout=1)[源代码]

Execute a single command on the mpv process and return the result.

get_property(name)[源代码]

Return the value of property name.

register_callback(name, callback)[源代码]

Register a function callback for the event name.

register_property_callback(name, callback)[源代码]

Register a function callback for the property-change event on property name.

set_property(name, value)[源代码]

Set the value of property name.

unregister_callback(name, callback)[源代码]

Unregister a previously registered function callback for the event name.

unregister_property_callback(name, callback)[源代码]

Unregister a previously registered function callback for the property-change event on property name.

class bilibilivoice.mpv.MPVBase(window_id=None, debug=False)[源代码]

Bases: object

Base class for communication with the mpv media player via unix socket based JSON IPC.

用于控制mpv的类,因为尝试通过管道控制mpv,但是好像mpv不支持管道...所有就 只能通过json来中间控制了

注解

提示

可以参考mpv的官方文档

https://mpv.io/manual/stable/

close()[源代码]

Shutdown the mpv process and our communication setup.

default_argv = ['--idle', '--no-input-default-bindings', '--no-terminal', '--no-video']
executable = None
is_running()[源代码]

Return True if the mpv process is still active.

exception bilibilivoice.mpv.MPVCommandError[源代码]

Bases: bilibilivoice.mpv.MPVError

exception bilibilivoice.mpv.MPVCommunicationError[源代码]

Bases: bilibilivoice.mpv.MPVError

exception bilibilivoice.mpv.MPVError[源代码]

Bases: Exception

exception bilibilivoice.mpv.MPVProcessError[源代码]

Bases: bilibilivoice.mpv.MPVError

exception bilibilivoice.mpv.MPVTimeoutError[源代码]

Bases: bilibilivoice.mpv.MPVError