-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: screensaver bugs, move controller routes to own file
- Loading branch information
Showing
5 changed files
with
146 additions
and
133 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import flask_babel | ||
from flask import Blueprint, redirect, request, url_for | ||
|
||
from pikaraoke.lib.current_app import broadcast_event, get_karaoke_instance | ||
|
||
_ = flask_babel.gettext | ||
|
||
|
||
controller_bp = Blueprint("controller", __name__) | ||
|
||
|
||
@controller_bp.route("/skip") | ||
def skip(): | ||
k = get_karaoke_instance() | ||
broadcast_event("skip", "user command") | ||
k.skip() | ||
return redirect(url_for("home.home")) | ||
|
||
|
||
@controller_bp.route("/pause") | ||
def pause(): | ||
k = get_karaoke_instance() | ||
if k.is_paused: | ||
broadcast_event("play") | ||
else: | ||
broadcast_event("pause") | ||
k.pause() | ||
return redirect(url_for("home.home")) | ||
|
||
|
||
@controller_bp.route("/transpose/<semitones>", methods=["GET"]) | ||
def transpose(semitones): | ||
k = get_karaoke_instance() | ||
broadcast_event("skip", "transpose current") | ||
k.transpose_current(int(semitones)) | ||
return redirect(url_for("home.home")) | ||
|
||
|
||
@controller_bp.route("/restart") | ||
def restart(): | ||
k = get_karaoke_instance() | ||
broadcast_event("restart") | ||
k.restart() | ||
return redirect(url_for("home.home")) | ||
|
||
|
||
@controller_bp.route("/volume/<volume>") | ||
def volume(volume): | ||
k = get_karaoke_instance() | ||
broadcast_event("volume", volume) | ||
k.volume_change(float(volume)) | ||
return redirect(url_for("home.home")) | ||
|
||
|
||
@controller_bp.route("/vol_up") | ||
def vol_up(): | ||
k = get_karaoke_instance() | ||
broadcast_event("volume", "up") | ||
k.vol_up() | ||
return redirect(url_for("home.home")) | ||
|
||
|
||
@controller_bp.route("/vol_down") | ||
def vol_down(): | ||
k = get_karaoke_instance() | ||
broadcast_event("volume", "down") | ||
k.vol_down() | ||
return redirect(url_for("home.home")) | ||
|
||
|
||
@controller_bp.route("/end_song", methods=["GET", "POST"]) | ||
def end_song(): | ||
k = get_karaoke_instance() | ||
d = request.form.to_dict() | ||
reason = d["reason"] if "reason" in d else None | ||
k.end_song(reason) | ||
return "ok" | ||
|
||
|
||
@controller_bp.route("/start_song", methods=["GET"]) | ||
def start_song(): | ||
k = get_karaoke_instance() | ||
k.start_song() | ||
return "ok" |
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
Oops, something went wrong.