diff --git a/proto/anki/frontend.proto b/proto/anki/frontend.proto index c9dde4e8d..bac47c8d2 100644 --- a/proto/anki/frontend.proto +++ b/proto/anki/frontend.proto @@ -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; diff --git a/qt/aqt/mediasrv.py b/qt/aqt/mediasrv.py index 15c3456f7..330c4c586 100644 --- a/qt/aqt/mediasrv.py +++ b/qt/aqt/mediasrv.py @@ -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) diff --git a/ts/routes/reviewer/reviewer-bottom/More.svelte b/ts/routes/reviewer/reviewer-bottom/More.svelte index a0cc6def2..2c953b8c3 100644 --- a/ts/routes/reviewer/reviewer-bottom/More.svelte +++ b/ts/routes/reviewer/reviewer-bottom/More.svelte @@ -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", diff --git a/ts/routes/reviewer/reviewer.ts b/ts/routes/reviewer/reviewer.ts index b61e0e791..8469efbf0 100644 --- a/ts/routes/reviewer/reviewer.ts +++ b/ts/routes/reviewer/reviewer.ts @@ -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; }