ライブラリhttps://github.com/jaseg/python-mpvを使用して mpv プレーヤーを制御していますが、pyside6 と組み合わせて使用すると、キーバインドが機能しません (プレーヤーが入力を完全に受け入れません)。私は何を間違っていますか?またはpyside6に埋め込むときにそれらを使用することは不可能ですか? (埋め込みなしで同じ引数でプレーヤーを実行すると、すべて正常に動作します)
import os
os.add_dll_directory(os.getcwd())
import mpv
from PySide6.QtWidgets import *
from PySide6.QtCore import *
mpvfolderpath = f"mpv.net/portable_config/"
import sys
class Test(QMainWindow):
def __init__(self, parent=None):
super().__init__(parent)
self.container = QWidget(self)
self.setCentralWidget(self.container)
self.container.setAttribute(Qt.WA_DontCreateNativeAncestors)
self.container.setAttribute(Qt.WA_NativeWindow)
player = mpv.MPV(wid=str(int(self.container.winId())),
vo="gpu", # You may not need this
log_handler=print,
loglevel='debug',
input_default_bindings=True,
input_vo_keyboard=True)
@player.on_key_press('f')
def my_f_binding():
print("f работает!")
player.play('test.mp4')
app = QApplication(sys.argv)
# This is necessary since PyQT stomps over the locale settings needed by libmpv.
# This needs to happen after importing PyQT before creating the first mpv.MPV instance.
import locale
locale.setlocale(locale.LC_NUMERIC, 'C')
win = Test()
win.show()
sys.exit(app.exec_())