Skip to content

Instantly share code, notes, and snippets.

@yusuke
Last active August 29, 2015 14:05
Show Gist options
  • Save yusuke/a00646e8bfaa9092c3c1 to your computer and use it in GitHub Desktop.
Save yusuke/a00646e8bfaa9092c3c1 to your computer and use it in GitHub Desktop.
ボリュームをリモートでコントロールするjsp
<%@ page language="java" contentType="text/html; charset=UTF-8" session="false"%><html>
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8">
<title>online volume controller</title>
</head>
<body><%request.setCharacterEncoding("UTF-8");
String volume = request.getParameter("volume");
try{
int volumeInt = Integer.parseInt(volume);
volumeInt = volumeInt < 0 ? 0 : volumeInt;
volumeInt = volumeInt >= 100 ? 100 : volumeInt;
float volumeDouble = volumeInt / 10;
new ProcessBuilder().command("osascript", "-e", "set Volume "+volumeDouble).start().waitFor();
out.print("volume set to : "+ volumeInt);
}catch(NumberFormatException nfe){
out.print("illegal volume value: "+ volume);
}
%></body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment