Skip to content

Instantly share code, notes, and snippets.

@pbuyle
Created January 2, 2009 21:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pbuyle/42700 to your computer and use it in GitHub Desktop.
Save pbuyle/42700 to your computer and use it in GitHub Desktop.
Simple script to control VLC (or any MPRIS media player) with the Tux Droid's remote control (http://www.kysoh.com/tux-droid)
#!/usr/bin/python
# -*- coding: UTF8 -*-
import dbus
from tuxisalive.api.TuxAPIConst import *
from tuxisalive.api.TuxAPI import TuxAPI
__author__ = 'mongolito404@gmail.com'
__appname__ = 'TuxVlcControl'
__version__ = '0.0.1'
__date__ = '2008/12/29'
__license__ = 'GPL'
bus = dbus.SessionBus()
player = bus.get_object('org.mpris.vlc', '/Player')
tux = TuxAPI('127.0.0.1', 270)
tux.server.autoConnect(CLIENT_LEVEL_RESTRICTED, __appname__, 'NONE')
tux.server.waitConnected(10.0)
tux.dongle.waitConnected(10.0)
tux.radio.waitConnected(10.0)
if tux.access.waitAcquire(10.0, ACCESS_PRIORITY_NORMAL):
def play_pause(*args):
status = player.GetStatus()
if(status[0]==2):
player.Play()
else:
player.Pause()
tux.button.remote.registerEventOnPressed(play_pause, K_PLAYPAUSE)
tux.button.remote.registerEventOnPressed(player.Stop, K_STOP)
tux.button.remote.registerEventOnPressed(player.Next(), K_NEXT)
tux.button.remote.registerEventOnPressed(player.Prev(), K_PREVIOUS)
def volume_plus(*args):
player.VolumeSet(player.VolumeGet() + 1)
tux.button.remote.registerEventOnPressed(volume_plus, K_VOLUMEPLUS)
def volume_minus(*args):
player.VolumeSet(player.VolumeGet() - 1)
tux.button.remote.registerEventOnPressed(volume_minus, K_VOLUMEMINUS)
while(not tux.button.remote.waitPressed(1000.0, K_STANDBY)):
pass
tux.access.release()
tux.server.disconnect()
tux.destroy()
bus.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment