#Is their a way to make only one audio source auto play on an anki card?

1 messages · Page 1 of 1 (latest)

weary garnet
#

Basically message above, I want to know if I can specify a card to auto play audio but have it only play one source of audio on the card.
In the example below that would mean hearing the sentence automatically and it not playing the clean version of the word.

heady flicker
#

Could you clarify a bit exactly what you mean? Do you want a card to only play sentence audio if sentence audio is available?

weary garnet
#

No I'm sorry. On the back my cards I have two audio sources, the sentence and a the word said alone. I was wondering if there is a way to make it only play the sentence audio automatically when I flip the card

heady flicker
#

Ah okay I think I understand. I don't think there's any way to make Anki only autoplay selected audio since the setting allows you to autoplay or not, so I don't think it's possible to achieve this. I'm not entirely sure why you'd want to not have the word audio play anyways since it's good to hear the word in isolation and in context since the way it sounds can differ

weary garnet
#

Ya, I didn't think it was possible from what I could find. Thanks for trying to help though. I agree having both is better, that's why I keep them both, I just don't like that it plays immediately. Have a nice evening sir

heady flicker
#

It sounds a bit weird to hear the sentence audio first and then word audio since I'm so used to it being the other way around. Usually there's a bit of quietness at the end of most word audio which makes it less jarring to go from word audio to sentence audio, so maybe you could try changing their order

weary garnet
#

Perhaps, so. I shall give it a try

serene abyss
#

Hi Pag, this is possible via the card template and JavaScript. If you provide me with your card Lay-out I can patch it up later the day / tomorrow for you.

weary garnet
# serene abyss Hi Pag, this is possible via the card template and JavaScript. If you provide me...

This is my current back template. Is this what you would need? Or would you just prefer an image?

<div class="back-box" style= 'background-color: #FDFFFF;'>

  <div class='wrapper'>
                 <div class="audio">
                 <div>{{SentenceAudio}}</div>
                  <div>{{Audio}}</div>
    </div>

    <div class='photo'>
      {{Picture}}
    </div>
  </div>
  
     <div style= 'color: #555b6e; font-size: 20px; padding-top: 25px;'> {{Reading}}<div>

<div class=reading style= 'color: #555b6e; margin-top: -20px;' >{{edit:furigana:front}}</div>

<div style= 'color: #555b6e; margin-top: -20px; font-size: 30px;'>{{Sentence}}</div>
  
<div class="glossary" style='font-family: Arial; font-size: 25px; color: #555b6e; margin-top: 10px;'>{{edit:Glossary}}</div>

<div style= 'padding-bottom: 20px; font-size: 30px; color: #555b6e'>{{Graph}}</div>

</div>

serene abyss
# weary garnet This is my current back template. Is this what you would need? Or would you just...

I may have forgotten it yesterday 😄

Basically what i did:

  • on the line with "SentenceAudio" i added the class="s_audio
  • on the bottom i added the section with the script

If you change the s_audio to w_audio inside the script-part (without anything else, dot etc) the word audio should play instead 🙂

<div class="back-box" style= 'background-color: #FDFFFF;'>
      <div class='wrapper'>
                     <div class="audio">
                     <div class="s_audio">{{SentenceAudio}}</div>
                      <div class="w_audio">{{Audio}}</div>
        </div>
        <div class='photo'>
          {{Picture}}
        </div>
      </div>
         <div style= 'color: #555b6e; font-size: 20px; padding-top: 25px;'> {{Reading}}<div>
    <div class=reading style= 'color: #555b6e; margin-top: -20px;' >{{edit:furigana:front}}</div>
    <div style= 'color: #555b6e; margin-top: -20px; font-size: 30px;'>{{Sentence}}</div>
    <div class="glossary" style='font-family: Arial; font-size: 25px; color: #555b6e; margin-top: 10px;'>{{edit:Glossary}}</div>
    <div style= 'padding-bottom: 20px; font-size: 30px; color: #555b6e'>{{Graph}}</div>
  </div>
<script>
function playAudio() {
  const audio = document.querySelector(
    ".s_audio .soundLink, #sentenceAudio .replaybutton"
  );

  if (audio) {
    audio.click();
  }
}

playAudio();
</script>
glacial coral
serene abyss
#

I never tried any alpha or whatsoever - however, it is basically the same code as the jp1k has embedded as well. It worked always for me ^^

#

Also, the js is that basic even old Internet Explorer could pull it off O.o

glacial coral
#

If mathjax doesn't load properly, the class mathjax-needs-to-render is never removed, which hides the entire card

#

I have no idea why mathjax is even related to playing audio, but 🤷

#

Yeah, forcing the mathjax-needs-to-render css class to have visibility: visible !important magically fixes it. What a strange bug

#

The other solution I was thinking of was splitting the regex string with something like "\\" + "]", but webpack optimizes it back into one full string 🤔