maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Multimedia (https://talk.maemo.org/forumdisplay.php?f=32)
-   -   [Announce] Mplayer touch screen control (https://talk.maemo.org/showthread.php?t=59498)

TorstenT 2010-07-30 22:29

[Announce] Mplayer touch screen control
 
Yet another mplayer interface !


As far as I know the media player is closed source and you have no chance to change the user interface.

But mplayer is flexible. Therefore I have written a python script and some shell scripts which control mplayer in slave mode via touch-screen. The keyboard is not necessary.

You can switch between the two menus by touching the lower left corner of the touch screen.

Here is an image how to control mplayer in virtual menu 1:
http://torsten-traenkner.de/wissen/n...trol_menu1.jpg

Here is an image how to control mplayer in virtual menu 2:
http://torsten-traenkner.de/wissen/n...trol_menu2.jpg

To quit mplayer press menu 2 (lower left corner) and then press quit (upper left corner).

Since I created the package by hand without scratchbox I am not sure if all dependencies are met. Let me know if something is missing.

Here is the package:
http://torsten-traenkner.de/wissen/n..._1.0_armel.deb

Local installation:
Code:

wget http://torsten-traenkner.de/wissen/n900/mplayer-touchcontrol_1.0_armel.deb
sudo gainroot
dpkg -i mplayer-touchcontrol_1.0_armel.deb

To use the scripts open a terminal and use "mm". For example:
Code:

mm /home/user/MyDocs/.videos/Nokia_N900.mp4

Currently mplayer is slow. Therefore the scripts might not be that useful. Maybe it is better to integrate the touch-screen interface in vlc.

The code can also be used for other applications.
Code:

The main script is:
/opt/maemo/usr/bin/mplayer-touchcontrol/touchscreenEvents.py

it reads the touch screen events from the touch screen device

/dev/input/ts

Torsten

jd4200 2010-08-05 18:01

Re: [Announce] Mplayer touch screen control
 
This looks neat. Any chance you can post the sources? I'd prefer to look at them before installing.

Bundyo 2010-08-05 20:32

Re: [Announce] Mplayer touch screen control
 
They are probably in the package (python + shell?).

TorstenT 2010-08-05 22:47

Re: [Announce] Mplayer touch screen control
 
Quote:

Originally Posted by jd4200 (Post 776836)
This looks neat. Any chance you can post the sources? I'd prefer to look at them before installing.

Read the sources without installation:

Code:

mkdir test
cd test
wget http://torsten-traenkner.de/wissen/n900/mplayer-touchcontrol_1.0_armel.deb
ar xv mplayer-touchcontrol_1.0_armel.deb
tar xzvf data.tar.gz
cd opt/maemo/usr/bin/mplayer-touchcontrol/
cat touchscreenEvents.py

Basically, I read the events from /dev/input/ts. These are 16 byte for each touch on the screen.

Meanwhile, I have found MediaBox. Maybe the touchscreen interface would fit best into MediaBox since it has a better performance than mplayer.

Here is the code of the main script:

Code:

#!/usr/bin/python
# -*- coding: utf-8 -*-

# needed for pack and unpack
import struct
# needed to execute process
import subprocess
# needed to flush
import sys

# positions/buttons on the touch screen:
#
#  1 | 2 | 3
# ---+---+---
#  4 | 5 | 6
# ---+---+---
#  7 | 8 | 9

x = 0
y = 0
z = 0
touchScreenDeviceName = "/dev/input/ts"

# int, int, short, short, int
format = 'iihhi'

def touchScreenpressed(x, y):
  # print "pressed: ",x," ",y
  if x > 530:
    position = 3
  elif x > 300:
    position = 2
  else:
    position = 1

  if y > 315:
    position = position + 6
  elif y > 170:
    position = position + 3

  print "position: ",position
  sys.stdout.flush()
  subprocess.call(\
  ["su user -c /opt/maemo/usr/bin/mplayer-touchcontrol/"+str(position)+".sh &",
  ""], shell=True)

# open file in binary mode
touchScreenDevice = open(touchScreenDeviceName,"rb")
event = touchScreenDevice.read(16)

while event:
  # read single values from the 16 bytes
  (time1, time2, type, code, value) = \
    struct.unpack(format, event)

  # absolute coordinates
  if type == 3:
    if code == 0:
      x = value
    if code == 1:
      y = value
    if code == 2:
      z = value

  # synchronisation of coordinates ready
  # if type == 0 and code == 0:
  #  print x, ":", y

  # touchscreen
  if type == 1 and code == 0x014a:
    # pressed
    if value == 1:
      x = x / 5
      y = 500 - (y / 8)

      #print "pressed : ", x, ":", y
      touchScreenpressed(x, y)

  # read next event
  event = touchScreenDevice.read(16)

Torsten

pycage 2010-08-06 04:26

Re: [Announce] Mplayer touch screen control
 
Quote:

Originally Posted by TorstenT (Post 777179)
Meanwhile, I have found MediaBox. Maybe the touchscreen interface would fit best into MediaBox since it has a better performance than mplayer.

Thanks for sharing. This could really be useful as a full screen control interface for MediaBox.


All times are GMT. The time now is 02:03.

vBulletin® Version 3.8.8