Added: Audio buttons

This commit is contained in:
Luc Mcgrady 2025-11-18 14:52:28 +00:00
parent 766b495efa
commit b1fbdce192
No known key found for this signature in database
GPG key ID: 4F3D7A0B17CC3D9C
4 changed files with 86 additions and 17 deletions

View file

@ -55,6 +55,7 @@ message PlayAVTagsRequest {
message ReviewerActionRequest {
enum ReviewerAction {
// Menus
EditCurrent = 0;
SetDueDate = 1;
CardInfo = 2;
@ -66,6 +67,13 @@ message ReviewerActionRequest {
Options = 6;
// "Congratulations"
Overview = 7;
// Audio
PauseAudio = 9;
SeekBackward = 10;
SeekForward = 11;
RecordVoice = 12;
ReplayRecorded = 13;
};
ReviewerAction menu = 1;

View file

@ -728,20 +728,25 @@ def play_avtags():
def reviewer_action():
reviewer = aqt.mw.reviewer
MENU_ENUM = ReviewerActionRequest.ReviewerAction
ACTION_ENUM = ReviewerActionRequest.ReviewerAction
def overview():
aqt.mw.moveToState("overview")
REVIEWER_ACTIONS = {
MENU_ENUM.EditCurrent: aqt.mw.onEditCurrent,
MENU_ENUM.SetDueDate: reviewer.on_set_due,
MENU_ENUM.CardInfo: reviewer.on_card_info,
MENU_ENUM.PreviousCardInfo: reviewer.on_previous_card_info,
MENU_ENUM.CreateCopy: reviewer.on_create_copy,
MENU_ENUM.Forget: reviewer.forget_current_card,
MENU_ENUM.Options: reviewer.onOptions,
MENU_ENUM.Overview: overview,
ACTION_ENUM.EditCurrent: aqt.mw.onEditCurrent,
ACTION_ENUM.SetDueDate: reviewer.on_set_due,
ACTION_ENUM.CardInfo: reviewer.on_card_info,
ACTION_ENUM.PreviousCardInfo: reviewer.on_previous_card_info,
ACTION_ENUM.CreateCopy: reviewer.on_create_copy,
ACTION_ENUM.Forget: reviewer.forget_current_card,
ACTION_ENUM.Options: reviewer.onOptions,
ACTION_ENUM.Overview: overview,
ACTION_ENUM.PauseAudio: reviewer.on_pause_audio,
ACTION_ENUM.SeekBackward: reviewer.on_seek_backward,
ACTION_ENUM.SeekForward: reviewer.on_seek_forward,
ACTION_ENUM.RecordVoice: reviewer.onRecordVoice,
ACTION_ENUM.ReplayRecorded: reviewer.onReplayRecorded,
}
req = ReviewerActionRequest.FromString(request.data)

View file

@ -96,12 +96,36 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
"hr",
// Audio
{ name: tr.actionsReplayAudio(), shortcut: "R", onClick: todo },
{ name: tr.studyingPauseAudio(), shortcut: "5", onClick: todo },
{ name: tr.studyingAudio5s(), shortcut: "6", onClick: todo },
{ name: tr.studyingAudioAnd5s(), shortcut: "7", onClick: todo },
{ name: tr.studyingRecordOwnVoice(), shortcut: "Shift+V", onClick: todo },
{ name: tr.studyingReplayOwnVoice(), shortcut: "V", onClick: todo },
{
name: tr.actionsReplayAudio(),
shortcut: "R",
onClick: state.replayAudio.bind(state),
},
{
name: tr.studyingPauseAudio(),
shortcut: "5",
onClick: state.pauseAudio.bind(state),
},
{
name: tr.studyingAudio5s(),
shortcut: "6",
onClick: state.AudioSeekBackward.bind(state),
},
{
name: tr.studyingAudioAnd5s(),
shortcut: "7",
onClick: state.AudioSeekForward.bind(state),
},
{
name: tr.studyingRecordOwnVoice(),
shortcut: "Shift+V",
onClick: state.RecordVoice.bind(state),
},
{
name: tr.studyingReplayOwnVoice(),
shortcut: "V",
onClick: state.ReplayRecorded.bind(state),
},
{
name: tr.actionsAutoAdvance(),
shortcut: "Shift+A",

View file

@ -142,6 +142,34 @@ export class ReviewerState {
this.reviewerAction(ReviewerActionRequest_ReviewerAction.Overview);
}
public replayAudio() {
if (this._answerShown) {
playAvtags({ tags: this._cardData!.answerAvTags });
} else {
playAvtags({ tags: this._cardData!.questionAvTags });
}
}
public pauseAudio() {
this.reviewerAction(ReviewerActionRequest_ReviewerAction.PauseAudio);
}
public AudioSeekBackward() {
this.reviewerAction(ReviewerActionRequest_ReviewerAction.SeekBackward);
}
public AudioSeekForward() {
this.reviewerAction(ReviewerActionRequest_ReviewerAction.SeekForward);
}
public RecordVoice() {
this.reviewerAction(ReviewerActionRequest_ReviewerAction.RecordVoice);
}
public ReplayRecorded() {
this.reviewerAction(ReviewerActionRequest_ReviewerAction.ReplayRecorded);
}
public toggleMarked() {
if (this._cardData && this.currentCard?.card?.noteId) {
const noteIds = [this.currentCard.card.noteId];
@ -238,7 +266,7 @@ export class ReviewerState {
}
case " ":
case "enter": {
if (!get(this.answerShown)) {
if (this._answerShown) {
this.showAnswer();
} else if (this._cardData?.acceptEnter ?? true) {
this.easeButtonPressed(2);
@ -346,8 +374,12 @@ export class ReviewerState {
this.updateHtml(await this.showTypedAnswer(this._cardData?.back || ""));
}
get _answerShown() {
return get(this.answerShown);
}
public easeButtonPressed(rating: number) {
if (!get(this.answerShown)) {
if (!this._answerShown) {
return;
}