Created
February 20, 2017 16:56
-
-
Save ymauray/73c061edabc066f40e48b997989c6554 to your computer and use it in GitHub Desktop.
Monitor for iDJC patched with the "on-air" signal
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/python2.7 | |
"""monitor.py | |
Monitors events from iDJC. | |
Requires IDJC 0.8.11 or higher. | |
Takes the profile you wish to monitor as the command line parameter. | |
""" | |
import sys | |
import gobject | |
from idjcmonitor import IDJCMonitor | |
def launch_handler(_, profile, pid): | |
""" Handler for the 'launch' signal """ | |
message = "launch : profile = %s, pid = %d" | |
print message % (profile, pid) | |
def voip_mode_changed_handler(_, mode): | |
""" Handler for the 'voip-mode-changed' signal """ | |
message = "voip mode changed : mode = %d" | |
print message % mode | |
def streamstate_changed_handler(_, numeric_id, connected, where): | |
""" Handler for the 'streamstate-changed' signal """ | |
message = "stream state changed : id = %d, connected = %d, where = %s" | |
print message % (numeric_id, connected, where) | |
def recordstate_changed_handler(_, numeric_id, recording, where): | |
""" Handler for the 'recordstate-changed' signal """ | |
message = "record state changed : id = %d, recording = %d, where = %s" | |
print message % (numeric_id, recording, where) | |
def channelstate_changed_handler(_, numeric_id, open_): | |
""" Handler for the 'channelstate-changed' signal """ | |
message = "channel state changed : id = %d, open = %d" | |
print message % (numeric_id, open_) | |
def metadata_changed_handler(_, artist, title, album, songname, music_filename): | |
""" Handler for the 'metadata-changed' """ | |
message = "metadata changed : artist = %s, title = %s, album = %s, " | |
message += "songname = %s, music_filename = %s" | |
print message % (artist, title, album, songname, music_filename) | |
def effect_started_handler(_, title, pathname, player): | |
""" Handler for the 'effect-started' signal """ | |
message = "effect started : title = %s, pathname = %s, player = %d" | |
print message % (title, pathname, player) | |
def effect_stopped_handler(_, player): | |
""" Handler for the 'effect-stopped' signal """ | |
message = "effect stopped : player = %d" | |
print message % (player) | |
def tracks_finishing_handler(_): | |
""" Handler for the 'tracks-finishing' signal """ | |
print "tracks finishing" | |
def frozen_handler(_, profile, pid, frozen): | |
""" Handler for the 'frozen' signal """ | |
message = "frozen: profile = %s, pid = %d, frozen = %d" | |
print message % (profile, pid, frozen) | |
def on_air_handler(_, active): | |
""" Handler for the 'on-air' signal """ | |
message = "on air : active = %d" | |
print message % (active) | |
def quit_handler(_, profile, pid): | |
""" Handler for the 'quit' signal """ | |
message = "quit : profile = %s, pid = %d" | |
print message % (profile, pid) | |
try: | |
PROFILE = sys.argv[1] | |
except IndexError: | |
PROFILE = "default" | |
MONITOR = IDJCMonitor(PROFILE) | |
MONITOR.connect("launch", launch_handler) | |
MONITOR.connect("streamstate-changed", streamstate_changed_handler) | |
MONITOR.connect("recordstate-changed", recordstate_changed_handler) | |
MONITOR.connect("channelstate-changed", channelstate_changed_handler) | |
MONITOR.connect("voip-mode-changed", voip_mode_changed_handler) | |
MONITOR.connect("metadata-changed", metadata_changed_handler) | |
MONITOR.connect("effect-started", effect_started_handler) | |
MONITOR.connect("effect-stopped", effect_stopped_handler) | |
MONITOR.connect("tracks-finishing", tracks_finishing_handler) | |
MONITOR.connect("frozen", frozen_handler) | |
MONITOR.connect("on-air", on_air_handler) | |
MONITOR.connect("quit", quit_handler) | |
gobject.MainLoop().run() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To run this, use :