I have a deck of cards consisting entirely of images (it displays one image on the front, and then the back just has another image that is the same size with the answer), and I would like to set it so that it auto-plays an audio file when you show the back, and then if you want to play the audio again, instead of there being a button, you can just click anywhere on the card to replay it.
My HTML/CSS ability is lower intermediate, and I’ve been able to figure out how to style the replay button, but I can’t figure out how to get rid of the button and just make the entire card clickable instead. Is there a way to do this?
I was able to style the .replay-button in CSS, so I could change the size and colors, even replace it with “”, without using any javascript. But I haven’t been able to figure out how to get rid of the button entirely and still have a way to click and play the audio.
As you can see, Anki’s audio buttons call the function pycmd, which sends a message to the Python side of things (wouldn’t call it backend, but something in-between).
The message consists of three parts: play:context:str_index
play: Tells Anki which arguments to expect and which function to call when it receives the message. You can see here how Anki reacts to the command within reviewer.py:
context: either q (question) or a (answer)
str_index: position of the sound file inside the card
Long story short, all you need to do is send a pycmd to tell Anki which soundfile to play, like this: