forked from server/soundboard
Implement video killing feature
This commit is contained in:
parent
ed62963858
commit
3e15a967f8
@ -11,6 +11,8 @@ app = Flask(__name__)
|
|||||||
app.jinja_env.trim_blocks = True
|
app.jinja_env.trim_blocks = True
|
||||||
app.jinja_env.lstrip_blocks = True
|
app.jinja_env.lstrip_blocks = True
|
||||||
|
|
||||||
|
processlist = []
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
@app.route("/play/<sound>")
|
@app.route("/play/<sound>")
|
||||||
@app.route("/say/", methods=["POST"])
|
@app.route("/say/", methods=["POST"])
|
||||||
@ -39,7 +41,17 @@ def index(sound=None, text=None, video=None):
|
|||||||
|
|
||||||
if video is not None:
|
if video is not None:
|
||||||
url = subprocess.check_output(["youtube-dl", "-g", "-f", "mp4", video]).decode()
|
url = subprocess.check_output(["youtube-dl", "-g", "-f", "mp4", video]).decode()
|
||||||
subprocess.Popen(["omxplayer", url.split("\n")[1]])
|
audioproc = subprocess.Popen(["omxplayer", url.split("\n")[1]])
|
||||||
subprocess.Popen(["omxplayer", "-b", url.split("\n")[0]])
|
videoproc = subprocess.Popen(["omxplayer", "-b", url.split("\n")[0]])
|
||||||
|
|
||||||
|
processlist.append(audioproc)
|
||||||
|
processlist.append(videoproc)
|
||||||
|
|
||||||
|
killvideo = request.args.get("killvideo")
|
||||||
|
|
||||||
|
if killvideo is not None and killvideo in ["1", "true", "yes"]:
|
||||||
|
for process in processlist:
|
||||||
|
process.terminate()
|
||||||
|
processlist.remove(process)
|
||||||
|
|
||||||
return render_template("index.html", sounds=sounds)
|
return render_template("index.html", sounds=sounds)
|
||||||
|
|||||||
@ -20,6 +20,7 @@ h1 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
form {
|
form {
|
||||||
|
padding: 5px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,6 +25,10 @@
|
|||||||
<input type="text" name="video" />
|
<input type="text" name="video" />
|
||||||
<input type="submit" value="Play" />
|
<input type="submit" value="Play" />
|
||||||
</form>
|
</form>
|
||||||
|
<form action="/" method="GET">
|
||||||
|
<input type="hidden" name="killvideo" value="yes" />
|
||||||
|
<input type="submit" name="submit" value="Terminate videos" />
|
||||||
|
</form>
|
||||||
</section>
|
</section>
|
||||||
<section id="voice">
|
<section id="voice">
|
||||||
<form action="/say/" method="POST">
|
<form action="/say/" method="POST">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user