This is a follow up question to this answer: https://stackoverflow.com/a/11939294/406686:
Consider the following code, which embeds mplayer in a QWidget
. The problem is that it doesn't react to any mplayer keyboard shortcuts such as right arrow for seek forward and so on.
It's clear that I can reimplement every shortcut manually. However is there a way to pipe all keyboard sequences automatically to mplayer as long as a modifier key, say ALT or Win-Key is pressed?
For example: Press ALT + → = seek forward...
import mpylayer
from PyQt4 import QtGui, QtCore
class Window(QtGui.QWidget):
def __init__(self):
QtGui.QWidget.__init__(self)
self.container = QtGui.QWidget(self)
self.container.setStyleSheet('background: black')
self.button = QtGui.QPushButton('Open', self)
self.button.clicked.connect(self.handleButton)
layout = QtGui.QVBoxLayout(self)
layout.addWidget(self.container)
layout.addWidget(self.button)
self.mplayer = mpylayer.MPlayerControl(
'mplayer', ['-wid', str(self.container.winId())])
def handleButton(self):
path = QtGui.QFileDialog.getOpenFileName()
if not path.isEmpty():
self.mplayer.loadfile(unicode(path))
if __name__ == '__main__':
import sys
app = QtGui.QApplication(sys.argv)
window = Window()
window.resize(640, 480)
window.show()
sys.exit(app.exec_())