2

I am trying to get an existing Python script which starts playing a song via mplayer to be able to interact with its keyboard input functionality (e.g. space to play/pause, arrow keys to fast forward/rewind).

I have tried using python-uinput, but running the example keyboard script does nothing (no errors). I executed modprobe input before running too.

I also tried python-evdev (after installing some other necessary dependencies), ran its example code and again there was no output, and also no errors.

I'm wondering if there is something that's causing both of these to not work the way they would on a full Linux build? Just a thought; really not sure what's going on. Any help is much appreciated, thanks!

I'm also open to other suggestions on how to control mplayer from a python script, besides simulating keyboard events.

Related post

Community
  • 1
  • 1
js3ph
  • 21
  • 3

2 Answers2

0

I guess you might have installed mplayer. If not please refer Intel Communities. If you come across this error

make: install: Command not found Makefile:910: recipe for target 'install-dirs' failed make: *** [install-dirs] Error 127

Install coreutils using AlexT's repo.

#opkg install coreutils

Also for python-evdev,

#opkg install python-pip #pip install evdev #python -m evdev.evtest

nraghuk
  • 156
  • 5
0

For uinput add import time at the top and time.sleep(0.5) before key press.

Worked for me today on a project using uinput

Sample:

import time
import uinput

device = uinput.Device([
    uinput.KEY_LEFTALT,
    uinput.KEY_TAB,
    ])

time.sleep(0.5)

device.emit_combo([
    uinput.KEY_LEFTALT,
    uinput.KEY_TAB,
    ])