-
-
Save jacek64/98a775216f8463e1c211b85f294fc72a to your computer and use it in GitHub Desktop.
control mplayer with python bottle web interface
This file contains 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
<html> | |
<head> | |
<link href="http://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.3/css/base/jquery.ui.all.css" rel="stylesheet"> | |
<link href="http://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.2/css/lightness/jquery-ui-1.10.2.custom.min.css" rel="stylesheet"> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/jqueryui-touch-punch/0.2.2/jquery.ui.touch-punch.min.js"></script> | |
<script src="http://localhost:8080/mplayer"></script> | |
<script> | |
$(function () { | |
$(".slider").each(function() { | |
console.info($(this)); | |
$(this).slider( | |
{ | |
min:$(this).data('min'), | |
max:$(this).data('max'), | |
step:$(this).data('step'), | |
slide: function(eventObject, ui) { | |
var input = $(eventObject.target).data(input); | |
mplayer($(this).data('input').replace('%value%', ui.value)) | |
} | |
} | |
); | |
}); | |
$("button").click(function() { | |
mplayer($(this).data('input')); | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<h1>speed</h1> | |
<div class="slider" data-input="speed_set %value%" data-min="0" data-max="4" data-step="0.01"></div> | |
<button data-input="speed_set 1" >normal</button> | |
<h1>volume</h1> | |
<div class="slider" data-input="volume %value% 1" data-min="0" data-max="100" data-step="1"></div> | |
<h1>reflector</h1> | |
<div class="slider" data-input="af_switch ladspa=/usr/lib64/ladspa/tap_reflector.so:tap_reflector:%value%:-90:10" data-min="0" data-max="1000" data-step="10"></div> | |
<h1>pitch</h1> | |
<div class="slider" data-input="af_switch ladspa=/usr/lib64/ladspa/tap_pitch.so:tap_pitch:%value%:0:-90:0" data-min="-12" data-max="12" data-step="0.1"></div> | |
<button data-input="af_add karaoke">karaoke</button> | |
<button data-input="af_switch ladspa=/usr/lib64/ladspa/autotalent.so:autotalent:440:0:0:0:-1.1:0:0:-1.1:0:-1.1:0:0:-1.1:0:-1.1:1:0:0:0:0:5:0:0:0:0:0:1">autotalent</button> | |
<button data-input="af_clr">clear filters</button> | |
</body> | |
</html> |
This file contains 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
#!/usr/bin/python | |
# Start mplayer using: mplayer -input file=mplayer-input | |
from bottle import route, run, request, post, static_file, response, default_app | |
@route('/mplayer') | |
def index(): | |
response.content_type = 'application/x-javascript' | |
return '''function mplayer(input) { | |
$.post('http://127.0.0.1:8080/mplayer', {'input':input}); | |
} | |
''' | |
@post('/mplayer') | |
def mplayer(): | |
response.set_header('Access-Control-Allow-Origin', '*'); | |
with open('/home/meeuw/mplayer-input', 'w') as f: | |
f.write(request.forms.get('input')+'\n') | |
run(default_app(), host='localhost', port=8080) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment