PlayAudio -> PlayAVTags

This commit is contained in:
Luc Mcgrady 2025-10-31 08:36:20 +00:00
parent 8da0491ae5
commit d47cb1bd55
No known key found for this signature in database
GPG key ID: 4F3D7A0B17CC3D9C
3 changed files with 11 additions and 11 deletions

View file

@ -32,8 +32,8 @@ service FrontendService {
// Save colour picker's custom colour palette // Save colour picker's custom colour palette
rpc SaveCustomColours(generic.Empty) returns (generic.Empty); rpc SaveCustomColours(generic.Empty) returns (generic.Empty);
// Plays the listed audio tags // Plays the listed AV tags
rpc PlayAudio(PlayAudioRequest) returns (generic.Empty); rpc PlayAVTags(PlayAVTagsRequest) returns (generic.Empty);
} }
service BackendFrontendService {} service BackendFrontendService {}
@ -48,6 +48,6 @@ message SetSchedulingStatesRequest {
scheduler.SchedulingStates states = 2; scheduler.SchedulingStates states = 2;
} }
message PlayAudioRequest { message PlayAVTagsRequest {
repeated card_rendering.AVTag tags = 1; repeated card_rendering.AVTag tags = 1;
} }

View file

@ -31,7 +31,7 @@ from anki import hooks
from anki.cards import Card from anki.cards import Card
from anki.collection import OpChanges, OpChangesOnly, Progress, SearchNode from anki.collection import OpChanges, OpChangesOnly, Progress, SearchNode
from anki.decks import UpdateDeckConfigs from anki.decks import UpdateDeckConfigs
from anki.frontend_pb2 import PlayAudioRequest from anki.frontend_pb2 import PlayAVTagsRequest
from anki.scheduler.v3 import SchedulingStatesWithContext, SetSchedulingStatesRequest from anki.scheduler.v3 import SchedulingStatesWithContext, SetSchedulingStatesRequest
from anki.scheduler_pb2 import NextCardDataResponse from anki.scheduler_pb2 import NextCardDataResponse
from anki.template import ( from anki.template import (
@ -693,8 +693,8 @@ def next_card_data() -> bytes:
return data.SerializeToString() return data.SerializeToString()
def play_audio(): def play_avtags():
req = PlayAudioRequest.FromString(request.data) req = PlayAVTagsRequest.FromString(request.data)
play_tags(av_tags_to_native(req.tags)) play_tags(av_tags_to_native(req.tags))
@ -715,7 +715,7 @@ post_handler_list = [
deck_options_ready, deck_options_ready,
save_custom_colours, save_custom_colours,
next_card_data, next_card_data,
play_audio, play_avtags,
] ]

View file

@ -1,7 +1,7 @@
// Copyright: Ankitects Pty Ltd and contributors // Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import { CardAnswer, type NextCardDataResponse_NextCardData } from "@generated/anki/scheduler_pb"; import { CardAnswer, type NextCardDataResponse_NextCardData } from "@generated/anki/scheduler_pb";
import { nextCardData, playAudio } from "@generated/backend"; import { nextCardData, playAvtags } from "@generated/backend";
import { derived, get, writable } from "svelte/store"; import { derived, get, writable } from "svelte/store";
import type { InnerReviewerRequest } from "../reviewer-inner/innerReviewerRequest"; import type { InnerReviewerRequest } from "../reviewer-inner/innerReviewerRequest";
import type { ReviewerRequest } from "./reviewerRequest"; import type { ReviewerRequest } from "./reviewerRequest";
@ -46,7 +46,7 @@ export class ReviewerState {
switch (e.data.type) { switch (e.data.type) {
case "audio": { case "audio": {
const tags = get(this.answerShown) ? this._cardData!.answerAvTags : this._cardData!.questionAvTags; const tags = get(this.answerShown) ? this._cardData!.answerAvTags : this._cardData!.questionAvTags;
playAudio({ tags: [tags[e.data.index]] }); playAvtags({ tags: [tags[e.data.index]] });
break; break;
} }
} }
@ -110,7 +110,7 @@ export class ReviewerState {
const question = resp.nextCard?.front || ""; const question = resp.nextCard?.front || "";
this.updateHtml(question, resp?.nextCard?.css, resp?.nextCard?.bodyClass); this.updateHtml(question, resp?.nextCard?.css, resp?.nextCard?.bodyClass);
playAudio({ tags: this._cardData!.questionAvTags }); playAvtags({ tags: this._cardData!.questionAvTags });
this.beginAnsweringMs = Date.now(); this.beginAnsweringMs = Date.now();
} }
@ -121,7 +121,7 @@ export class ReviewerState {
public showAnswer() { public showAnswer() {
this.answerShown.set(true); this.answerShown.set(true);
playAudio({ tags: this._cardData!.answerAvTags }); playAvtags({ tags: this._cardData!.answerAvTags });
this.updateHtml(this._cardData?.back || ""); this.updateHtml(this._cardData?.back || "");
} }