I have a card type that autoplays several media fields in sequence – some fields have a single audio file ([sound:__.mp3]
tag), some multiple.
My goal:
Every now and then, I have a note where I want some of the audio files to autoplay, but for others to be skipped. I want the skipped ones to still show up as play buttons, so I can manually play them if I want to – but it’s fine (or even preferrable) if they look a little different than the standard play button. Needs to work on Desktop and AnkiDroid.
My question:
Is there an easier/“lighter-weight” way to do this than the add-on? If I use the add-on, is there anyway I can get its controls/button closer to the standar play button? I appreciate any advice!
Tried:
I was hoping to find some sort of native-Anki or HTML-based “mute” or “skip” I could put around the sound tag in the field, and that would “hide” it from autoplay, but had no luck at that.
Potential add-on solution:
The Inline media add-on could work. I can add the to-be-skipped audio as inline media instead of a sound tag, and set it to not autoplay. But there are drawbacks –
- It’s more complicated than what I wanted.
- I don’t like having primary functionality on my cards that I don’t understand.
- I’m beholden to an add-on to continue working if I want to edit this or do it again on another note in the future. [The add-on is already out-dated and having some issues, which I’ll take up in the support thread if I can’t find another solution.]
- [The most disappointing thing] It displays a full bar of audio-player controls for each file – which stands out like a sore thumb in my nice orderly row of play buttons.
The <audio> element added by Inline media add-on --
<audio id="im-media-f194a080-8432-45e8-b296-efa0c0402da0" class="inline-media" src="_im-media-f194a080-8432-45e8-b296-efa0c0402da0.mp3" controls="" oncanplay="if(this.getRootNode().querySelector('anki-editable') === null && this.offsetParent !== null && ((this.hasAttribute('auto_front') && !document.body.classList.contains('back')) || (this.hasAttribute('auto_back') && document.body.classList.contains('back')))) {this.play();}" oncontextmenu="pycmd(this.id); return true;"></audio>
Potential fix to the add-on solution:
I found a way to tweak the full-bar controls on Stack Overflow – by deleting “controls” from the audio element and adding a button. This part at least I sort of understand! But I don’t know how to put anything on the button except text and emoji. So the result is lackluster. On top of that, without “controls” I lose my ability to interact with the fuctionality of the add-on.
The <button> element idea --
<button onclick="document.getElementById('im-media-f194a080-8432-45e8-b296-efa0c0402da0').play()">Play ▶️</button>
html - HTML5 Audio display only play pause and mute buttons - Stack Overflow