changeset 732:440d116ba5df

asco: add switcher to pick the pulseaudio sink Ignore-this: 57af0bce1573ecefc1536fe98c301a8f
author Drew Perttula <drewp@bigasterisk.com>
date Fri, 15 Jun 2012 01:57:52 +0000
parents 9cd3a28d6929
children 53da47fd5a90
files bin/movesinks light9/ascoltami/index.html light9/ascoltami/webapp.py
diffstat 3 files changed, 26 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/movesinks	Fri Jun 15 01:57:52 2012 +0000
@@ -0,0 +1,14 @@
+#!/bin/bash 
+
+# from http://askubuntu.com/questions/71863/how-to-change-pulseaudio-sink-with-pacmd-set-default-sink-during-playback/113322#113322
+
+echo "Setting default sink to: $1";
+pacmd set-default-sink $1
+pacmd list-sink-inputs | grep index | while read line
+do
+echo "Moving input: ";
+echo $line | cut -f2 -d' ';
+echo "to sink: $1";
+pacmd move-sink-input `echo $line | cut -f2 -d' '` $1
+
+done
--- a/light9/ascoltami/index.html	Thu Jun 14 08:11:21 2012 +0000
+++ b/light9/ascoltami/index.html	Fri Jun 15 01:57:52 2012 +0000
@@ -29,6 +29,9 @@
       <button id="cmd-intro">Skip intro <div class="key">i</div></button>
       <button id="cmd-post">Skip to Post <div class="key">t</div></button>
       <button id="cmd-go">Go  <div class="key">space</div></button>
+
+      <button id="cmd-out0">Output 0</button>
+      <button id="cmd-out1">Output 1</button>
     </div>
 
     todo: go button actions, display next action
@@ -118,6 +121,8 @@
     $("#cmd-go").click(function () {
 	// todo
     });
+    $("#cmd-out0").click(function () { $.post("output", tojs({sink: "0"})); })
+    $("#cmd-out1").click(function () { $.post("output", tojs({sink: "1"})); })
 
     var pendingSlide = false;
     $("#timeSlider").slider({
--- a/light9/ascoltami/webapp.py	Thu Jun 14 08:11:21 2012 +0000
+++ b/light9/ascoltami/webapp.py	Fri Jun 15 01:57:52 2012 +0000
@@ -1,4 +1,4 @@
-import web, json, socket
+import web, json, socket, subprocess
 from twisted.python.util import sibpath
 from light9.namespaces import L9
 from light9.showconfig import getSongsFromShow, songOnDisk
@@ -93,6 +93,11 @@
             player.seek(data['t'])
             player.resume()
 
+class output(object):
+    def POST(self):
+        d = json.loads(web.data())
+        subprocess.check_call(["bin/movesinks", str(d['sink'])])
+
 def makeWebApp(theApp):
     global app
     app = theApp
@@ -102,6 +107,7 @@
             r"/song", "songResource",
             r"/songs", "songs",
             r"/seekPlayOrPause", "seekPlayOrPause",
+            r"/output", "output",
             )
 
     return web.application(urls, globals(), autoreload=False)