Last active
August 29, 2015 14:05
-
-
Save yusuke/a00646e8bfaa9092c3c1 to your computer and use it in GitHub Desktop.
ボリュームをリモートでコントロールするjsp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ 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