Changeset - 440d116ba5df
[Not reviewed]
default
0 2 1
Drew Perttula - 13 years ago 2012-06-15 01:57:52
drewp@bigasterisk.com
asco: add switcher to pick the pulseaudio sink
Ignore-this: 57af0bce1573ecefc1536fe98c301a8f
3 files changed with 26 insertions and 1 deletions:
0 comments (0 inline, 0 general)
bin/movesinks
Show inline comments
 
new file 100644
 
#!/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
light9/ascoltami/index.html
Show inline comments
 
@@ -8,48 +8,51 @@
 
    <script type="text/javascript" src="static/jquery-1.4.2.min.js"></script>
 
      <script type="text/javascript" src="static/jquery-ui-1.8.2.custom/js/jquery-ui-1.8.2.custom.min.js"></script>
 
      <link rel="Stylesheet" type="text/css" href="static/jquery-ui-1.8.2.custom/css/smoothness/jquery-ui-1.8.2.custom.css"/>
 
      <link rel="Stylesheet" type="text/css" href="static/style.css"/>
 
  </head>
 
  <body>
 
    <h1>ascoltami on ${host}</h1>
 
    <div class="songs"/>
 

	
 
    <div>Song: <span id="currentSong"/></div>
 
    <div>Time: <span id="currentTime"/></div>
 
    <div>Left: <span id="leftTime"/></div>
 
    <div>Until autostop: <span id="leftAutoStopTime"/></div>
 
    <div>States: <span id="states"/></div>
 
    <div class="timeRow">
 
      <div id="timeSlider"/>
 
    </div>
 

	
 
    <div class="commands">
 
      <button id="cmd-stop" class="playMode">Stop<div class="key">s</div></button>
 
      <button id="cmd-play" class="playMode">Play <div class="key">p</div></button>
 
      <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
 
    <a href="">reload</a>
 

	
 
<script type="text/javascript">
 
// <![CDATA[
 
$(function () {
 

	
 
    var times = { // need to get these from server
 
	intro: 4,
 
	post: 4
 
    };
 

	
 
    var currentDuration = 0;
 
    var currentHighlightedSong = "";
 
    var lastPlaying;
 
    function updateCurrent(doneCallback) {
 
	$.getJSON("time", {}, function (data, status) {
 
	    $("#currentSong").text(data.song);
 
	    if (data.song != currentHighlightedSong) {
 
		showCurrentSong(data.song);
 
	    }
 
	    $("#currentTime").text(data.t.toFixed(1));
 
@@ -97,48 +100,50 @@
 
    var tojs = JSON.stringify;
 

	
 
    $(document).keypress(function (ev) {
 

	
 
	if (ev.which == 115) { $("#cmd-stop").click(); return false; }
 
	if (ev.which == 112) { $("#cmd-play").click(); return false; }
 
	if (ev.which == 105) { $("#cmd-intro").click(); return false; }
 
	if (ev.which == 116) { $("#cmd-post").click(); return false; }
 

	
 
	if (ev.which == 32) { $("#cmd-go").click(); return false; }
 
	return true;
 
    });
 

	
 
    $("#cmd-stop").click(function () { $.post("time", tojs({pause: true})); });
 
    $("#cmd-play").click(function () { $.post("time", tojs({resume: true})); });
 
    $("#cmd-intro").click(function () { 
 
	$.post("time", tojs({t: times.intro, resume: true}))
 
    });
 
    $("#cmd-post").click(function () { 
 
	$.post("time", tojs({t: currentDuration - times.post, resume: true}))
 
    });
 
    $("#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({
 
	step: .01,
 
	slide: function (event, ui) {
 
	    if (pendingSlide) {
 
		return;
 
	    }
 
	    pendingSlide = true;
 
	    $.post("time", '{"t" : '+ui.value+'}', 
 
		   function (data, status, xhr) {
 
		       pendingSlide = false;
 
		   });
 
	},
 
    });
 
    
 
    var raf = window.requestAnimationFrame ||
 
	window.mozRequestAnimationFrame || 
 
	window.webkitRequestAnimationFrame;
 

	
 
    function updateLoop() {
 
	var whenDone = function () {
 
	    setTimeout(function () { 
 
		raf(updateLoop);
light9/ascoltami/webapp.py
Show inline comments
 
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
 
from rdflib import URIRef
 
from web.contrib.template import render_genshi
 
render = render_genshi([sibpath(__file__, ".")])
 
app = None
 

	
 

	
 
_songUris = {} # locationUri : song
 
def songLocation(graph, songUri):
 
    loc = URIRef("file://%s" % songOnDisk(songUri))
 
    _songUris[loc] = songUri
 
    return loc
 
    
 
def songUri(graph, locationUri):
 
    return _songUris[locationUri]
 

	
 
class root(object):
 
    def GET(self):
 
        web.header("Content-type", "application/xhtml+xml")
 
        # todo: use a template; embed the show name and the intro/post
 
        # times into the page
 
        return render.index(host=socket.gethostname())
 
@@ -72,36 +72,42 @@ class songs(object):
 
            {"uri" : s,
 
             "path" : graph.value(s, L9['showPath']),
 
             "label" : graph.label(s)} for s in songs]})
 

	
 
class songResource(object):
 
    def POST(self):
 
        """post a uri of song to switch to (and start playing)"""
 
        graph = app.graph
 

	
 
        app.player.setSong(songLocation(graph, URIRef(web.data())))
 
        web.header("content-type", "text/plain")
 
        return "ok"
 
    
 
class seekPlayOrPause(object):
 
    def POST(self):
 
        player = app.player
 

	
 
        data = json.loads(web.data())
 
        if player.isPlaying():
 
            player.pause()
 
        else:
 
            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
 

	
 
    urls = (r"/", "root",
 
            r"/time", "timeResource",
 
            r"/song", "songResource",
 
            r"/songs", "songs",
 
            r"/seekPlayOrPause", "seekPlayOrPause",
 
            r"/output", "output",
 
            )
 

	
 
    return web.application(urls, globals(), autoreload=False)
0 comments (0 inline, 0 general)