Web remote controls
I can play, pause, stop, and advance to the next song through the web interface.
This commit is contained in:
parent
acecb18120
commit
a88f8225a7
|
@ -30,7 +30,10 @@ def body(wfile, args):
|
||||||
img_ar = artist.replace("/", "%2F")
|
img_ar = artist.replace("/", "%2F")
|
||||||
img_al = album.replace("/", "%2F")
|
img_al = album.replace("/", "%2F")
|
||||||
wfile.write("<tr><td><table align=center width=100%><tr>")
|
wfile.write("<tr><td><table align=center width=100%><tr>")
|
||||||
wfile.write("<td align=center><img src=\"artwork/%s/%s.jpg\" height=192/></td>" % (img_ar, img_al))
|
wfile.write("<td align=center><table align=center width=100%>")
|
||||||
|
wfile.write("<tr><td align=center>")
|
||||||
|
wfile.write("<img src=\"artwork/%s/%s.jpg\" height=192/></td></tr>" % (img_ar, img_al))
|
||||||
|
wfile.write("<tr><td align=center id=\"audio\"></td></tr></table>")
|
||||||
wfile.write("<td align><table align=left>\n")
|
wfile.write("<td align><table align=left>\n")
|
||||||
|
|
||||||
titles = []
|
titles = []
|
||||||
|
@ -46,11 +49,6 @@ def body(wfile, args):
|
||||||
wfile.write("</table></td>")
|
wfile.write("</table></td>")
|
||||||
wfile.write("</tr></table></td></tr>")
|
wfile.write("</tr></table></td></tr>")
|
||||||
|
|
||||||
wfile.write("<tr><td id=\"audio\">")
|
|
||||||
#wfile.write("<audio src=\"140401.ogg\" autoplay controls/>")
|
|
||||||
#wfile.write("Text when no audio")
|
|
||||||
wfile.write("</td></tr>")
|
|
||||||
|
|
||||||
wfile.write("</table>")
|
wfile.write("</table>")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<script type="text/javascript">
|
||||||
|
function do_request(action)
|
||||||
|
{
|
||||||
|
var http = new XMLHttpRequest();
|
||||||
|
http.open('GET', "controls.py?a="+action, true);
|
||||||
|
http.send();
|
||||||
|
return http;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*function get_response(http)
|
||||||
|
{
|
||||||
|
while (http.readyState != 4)
|
||||||
|
{}
|
||||||
|
|
||||||
|
var resp = http.responseText;
|
||||||
|
return resp;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
function control(action)
|
||||||
|
{
|
||||||
|
var http = do_request(action);
|
||||||
|
/*var resp = get_response(http);*/
|
||||||
|
}
|
||||||
|
|
||||||
|
function play()
|
||||||
|
{
|
||||||
|
control("play");
|
||||||
|
var button = document.getElementById("play_pause");
|
||||||
|
button.innerHTML = "<img src=\"stock_media-pause.png\" onclick=\"pause();\">";
|
||||||
|
}
|
||||||
|
|
||||||
|
function pause()
|
||||||
|
{
|
||||||
|
control("pause");
|
||||||
|
var button = document.getElementById("play_pause");
|
||||||
|
button.innerHTML = "<img src=\"stock_media-play.png\" onclick=\"play();\">";
|
||||||
|
}
|
||||||
|
|
||||||
|
function stop()
|
||||||
|
{
|
||||||
|
control("stop");
|
||||||
|
var button = document.getElementById("play_pause");
|
||||||
|
button.innerHTML = "<img src=\"stock_media-play.png\" onclick=\"play();\">";
|
||||||
|
}
|
||||||
|
|
||||||
|
function next()
|
||||||
|
{
|
||||||
|
control("next");
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td id="play_pause">
|
||||||
|
<img src="stock_media-play.png" onclick="play();"/>
|
||||||
|
</td><td>
|
||||||
|
<img src="stock_media-stop.png" onclick="stop();"/>
|
||||||
|
</td><td>
|
||||||
|
<img src="stock_media-next.png" onclick="next();"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
|
@ -0,0 +1,23 @@
|
||||||
|
# Bryan Schumaker (11/18/2010)
|
||||||
|
|
||||||
|
import libsaria.audio
|
||||||
|
import libsaria.sources
|
||||||
|
|
||||||
|
play = libsaria.audio.play
|
||||||
|
pause = libsaria.audio.pause
|
||||||
|
stop = libsaria.audio.stop
|
||||||
|
next = libsaria.sources.plist_next
|
||||||
|
|
||||||
|
|
||||||
|
def to_html(wfile, args):
|
||||||
|
action = args["a"]
|
||||||
|
ret = False
|
||||||
|
if action == "play":
|
||||||
|
ret = play()
|
||||||
|
elif action == "pause":
|
||||||
|
ret = pause()
|
||||||
|
elif action == "stop":
|
||||||
|
ret = stop()
|
||||||
|
elif action == "next":
|
||||||
|
ret = next()
|
||||||
|
wfile.write(str(ret))
|
|
@ -12,6 +12,7 @@ function message()
|
||||||
<body>
|
<body>
|
||||||
<!--<a id="bryan" onclick="message();">Text</a>-->
|
<!--<a id="bryan" onclick="message();">Text</a>-->
|
||||||
<a href="library.py">Library Browser</a>
|
<a href="library.py">Library Browser</a>
|
||||||
|
<a href="controls.html">Remote Controls</a>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
Binary file not shown.
After Width: | Height: | Size: 875 B |
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
After Width: | Height: | Size: 837 B |
|
@ -111,7 +111,7 @@ def rand_next():
|
||||||
return id
|
return id
|
||||||
|
|
||||||
def next():
|
def next():
|
||||||
if libsaria.prefs2.get_pref("libsaria.random") == True:
|
if libsaria.prefs.get_pref("libsaria.random") == True:
|
||||||
id = rand_next()
|
id = rand_next()
|
||||||
else:
|
else:
|
||||||
id = seq_next()
|
id = seq_next()
|
||||||
|
|
|
@ -19,8 +19,8 @@ html = join(path.cwd(), "html")
|
||||||
server = None
|
server = None
|
||||||
types = {".html":"text/html", ".js":"text/javascript",
|
types = {".html":"text/html", ".js":"text/javascript",
|
||||||
".ico":"image/vnd.microsoft.icon",
|
".ico":"image/vnd.microsoft.icon",
|
||||||
".py":"text/html", ".jpg":"image/jpeg",
|
".png":"image/png", ".jpg":"image/jpeg",
|
||||||
".mp3":"audio/mpeg",
|
".py":"text/html", ".mp3":"audio/mpeg",
|
||||||
".ogg":"audio/ogg"}
|
".ogg":"audio/ogg"}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue