# HG changeset patch # User drewp@bigasterisk.com # Date 2010-06-13 09:19:49 # Node ID 5cf326ef965a337a5ff72a0e51cf141827b087c0 # Parent 571d058c9838782d6137d01a523b16d5a93b63c2 cleanup asco to use song uris consistently. showPaths are now file: uris Ignore-this: 8ca9cfa22e340760c02a980009499ca3 diff --git a/light9/ascoltami/index.html b/light9/ascoltami/index.html --- a/light9/ascoltami/index.html +++ b/light9/ascoltami/index.html @@ -67,7 +67,7 @@ function showCurrentSong(uri) { $(".songs div").each(function (i, row) { row = $(row); - if (row.find("button").data("path") == uri) { + if (row.find("button").data("uri") == uri) { row.addClass("currentSong"); } else { row.removeClass("currentSong"); @@ -81,7 +81,7 @@ button.text(song.label); button.data(song); button.click(function () { - $.post("song", button.data("path"), + $.post("song", button.data("uri"), function (data, textStatus, xhr) { showCurrentSong(song.uri); }); diff --git a/light9/ascoltami/webapp.py b/light9/ascoltami/webapp.py --- a/light9/ascoltami/webapp.py +++ b/light9/ascoltami/webapp.py @@ -1,11 +1,24 @@ import web, jsonlib from twisted.python.util import sibpath from light9.namespaces import L9 - +from rdflib import URIRef player = None graph = None show = None + +def songLocation(graph, songUri): + loc = graph.value(songUri, L9['showPath']) + if loc is None: + raise ValueError("no showPath for %r" % songUri) + return loc + +def songUri(graph, locationUri): + try: + return graph.subjects(L9['showPath'], locationUri).next() + except StopIteration: + raise ValueError("no song has :showPath of %r" % locationUri) + class root(object): def GET(self): web.header("Content-type", "application/xhtml+xml") @@ -15,13 +28,24 @@ class root(object): class timeResource(object): def GET(self): - return jsonlib.write({"song" : player.playbin.get_property("uri"), - "started" : player.playStartTime, - "duration" : player.duration(), - "playing" : player.isPlaying(), - "t" : player.currentTime()}) + playingLocation = player.playbin.get_property("uri") + if playingLocation: + song = songUri(graph, URIRef(playingLocation)) + else: + song = None + return jsonlib.write({ + "song" : song, + "started" : player.playStartTime, + "duration" : player.duration(), + "playing" : player.isPlaying(), + "t" : player.currentTime()}) def POST(self): + """ + post a json object with {pause: true} or {resume: true} if you + want those actions. Use {t: } to seek, optionally + with a pause/resume command too. + """ params = jsonlib.read(web.data(), use_float=True) if params.get('pause', False): player.pause() @@ -48,7 +72,7 @@ class songs(object): class songResource(object): def POST(self): """post a uri of song to switch to (and start playing)""" - player.setSong(web.data()) + player.setSong(songLocation(graph, URIRef(web.data()))) return "ok" class seekPlayOrPause(object): diff --git a/show/dance2010/config.n3 b/show/dance2010/config.n3 --- a/show/dance2010/config.n3 +++ b/show/dance2010/config.n3 @@ -25,23 +25,23 @@ show:dance2010 :playList ( sh:song11, sh:song12, sh:song13, sh:song14, sh:song15, sh:song16, sh:song17 . -sh:song1 rdfs:label "1 chorus"; :showPath "file:///my/proj/light9/show/dance2010/music/01-chorusmix.wav" . -sh:song2 rdfs:label "2 dolly"; :showPath "file:///my/proj/light9/show/dance2010/music/02-dolly.wav" . -sh:song3 rdfs:label "3 opposites"; :showPath "file:///my/proj/light9/show/dance2010/music/03-oppositesmix.wav" . -sh:song4 rdfs:label "4 top hat"; :showPath "file:///my/proj/light9/show/dance2010/music/04-tophat.wav" . -sh:song5 rdfs:label "5 temple"; :showPath "file:///my/proj/light9/show/dance2010/music/05-temple.wav" . -sh:song6 rdfs:label "6 "; :showPath "file:///my/proj/light9/show/dance2010/music/06-contemporarymix.wav" . -sh:song7 rdfs:label "7 jackson"; :showPath "file:///my/proj/light9/show/dance2010/music/07-jacksonmix-complete.wav" . -sh:song8 rdfs:label "8 singing"; :showPath "file:///my/proj/light9/show/dance2010/music/08-singingmix.wav" . -sh:song9 rdfs:label "9 abc"; :showPath "file:///my/proj/light9/show/dance2010/music/09-abc.wav" . -sh:song10 rdfs:label "10 ritz"; :showPath "file:///my/proj/light9/show/dance2010/music/10-ritz.wav" . -sh:song11 rdfs:label "11 black or white"; :showPath "file:///my/proj/light9/show/dance2010/music/11-blackmix.wav" . -sh:song12 rdfs:label "12 eleanor"; :showPath "file:///my/proj/light9/show/dance2010/music/12-eleanor.wav" . -sh:song13 rdfs:label "13 sleeping"; :showPath "file:///my/proj/light9/show/dance2010/music/13-sleepingmix.wav" . -sh:song14 rdfs:label "14 charity"; :showPath "file:///my/proj/light9/show/dance2010/music/14-charitymix.wav" . -sh:song15 rdfs:label "15 fosse"; :showPath "file:///my/proj/light9/show/dance2010/music/15-fossemix.wav" . -sh:song16 rdfs:label "16 hip hop"; :showPath "file:///my/proj/light9/show/dance2010/music/16-hiphopmix.wav" . -sh:song17 rdfs:label "17 broadway"; :showPath "file:///my/proj/light9/show/dance2010/music/17-broadwaymix.wav" . +sh:song1 rdfs:label "1 chorus"; :showPath . +sh:song2 rdfs:label "2 dolly"; :showPath . +sh:song3 rdfs:label "3 opposites"; :showPath . +sh:song4 rdfs:label "4 top hat"; :showPath . +sh:song5 rdfs:label "5 temple"; :showPath . +sh:song6 rdfs:label "6 "; :showPath . +sh:song7 rdfs:label "7 jackson"; :showPath . +sh:song8 rdfs:label "8 singing"; :showPath . +sh:song9 rdfs:label "9 abc"; :showPath . +sh:song10 rdfs:label "10 ritz"; :showPath . +sh:song11 rdfs:label "11 black or white"; :showPath . +sh:song12 rdfs:label "12 eleanor"; :showPath . +sh:song13 rdfs:label "13 sleeping"; :showPath . +sh:song14 rdfs:label "14 charity"; :showPath . +sh:song15 rdfs:label "15 fosse"; :showPath . +sh:song16 rdfs:label "16 hip hop"; :showPath . +sh:song17 rdfs:label "17 broadway"; :showPath . sub:red :group group:strip; :order 0 . sub:orange :group group:strip; :order 1 .