update refactoring and add new features
This commit is contained in:
@@ -7,6 +7,7 @@ This is the central hub for all Python-mpv IPC communication. The Lua script
|
||||
should use the Python CLI, which uses this module to manage mpv connections.
|
||||
"""
|
||||
|
||||
import atexit
|
||||
import ctypes
|
||||
import json
|
||||
import os
|
||||
@@ -901,6 +902,7 @@ class MPVIPCClient:
|
||||
self.is_windows = platform.system() == "Windows"
|
||||
self.silent = bool(silent)
|
||||
self._recv_buffer: bytes = b""
|
||||
atexit.register(self.disconnect)
|
||||
|
||||
def _write_payload(self, payload: str) -> None:
|
||||
if not self.sock:
|
||||
@@ -1229,10 +1231,6 @@ class MPVIPCClient:
|
||||
self.sock = None
|
||||
self._recv_buffer = b""
|
||||
|
||||
def __del__(self) -> None:
|
||||
"""Cleanup on object destruction."""
|
||||
self.disconnect()
|
||||
|
||||
def __enter__(self):
|
||||
"""Context manager entry."""
|
||||
self.connect()
|
||||
|
||||
Reference in New Issue
Block a user