Skip to content

Instantly share code, notes, and snippets.

@Gottox
Last active December 27, 2015 16:09
Show Gist options
  • Save Gottox/7353204 to your computer and use it in GitHub Desktop.
Save Gottox/7353204 to your computer and use it in GitHub Desktop.
Plain Javascript/HTML Client for MPD.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script type="text/javascript">
function command(cmd) {
var http = new XMLHttpRequest();
var params = cmd+"\nclose\n";
var host = document.getElementById("host").value;
var port = document.getElementById("port").value;
http.open("POST", "http://"+host+":"+port, true);
http.send(params);
http.onreadystatechange = function() {//Call a function when the state changes.
console.log(http);
console.log(arguments);
}
}
</script>
</head>
<body>
Host: <input id="host" value="localhost"> |
<input id="port" type="number" value="6600"> <br>
<a href="javascript:void(command('previous'))">&#9194;</a>
<a href="javascript:void(command('play'))">&#9654;</a>
<a href="javascript:void(command('pause'))">||</a>
<a href="javascript:void(command('next'))">&#9193;</a>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment