Created
January 2, 2009 21:17
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: UTF8 -*- | |
import dbus | |
from tuxisalive.api.TuxAPIConst import * | |
from tuxisalive.api.TuxAPI import TuxAPI | |
__author__ = '[email protected]' | |
__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