audio file name from a field

46 views
Skip to first unread message

Stephen Kimmel

unread,
Dec 31, 2018, 11:46:24 AM12/31/18
to TiddlyWiki
I'm working on a variation of Wim Moermans Flashcards to Go routine but I want to add audio from an external directory to the individual flashcards. What I have, at the moment, is a statement like the one below in each flashcard tiddler.

<audio controls="controls"><source src="file:///C:/Users/Stephen/Downloads/JapaneseWords/xxx.mp3" type="audio/mp3"></audio>

I now have hundreds of these lines in my wiki where the only variation is the specific file name, xxx. What I like to do is put the filename, xxx, in a field and then have a single macro that would use that filename and create the equivalent. This ought to be simple but so far everything I've tried has failed.

Can someone point me in the right direction?

Mark S.

unread,
Dec 31, 2018, 3:53:45 PM12/31/18
to TiddlyWiki
You can make a tiddler and tag it $:/tags/Macro :

\define myaudio(file)
<audio controls="controls"><source src="./$file$.mp3" type="audio/mp3"/></audio>
\end


and then invoke the macro  as

<$macrocall $name="myaudio" file={{!!path}}/>


where "path" is the field holding the stem file name. You will have to change the full src path in your macro (I had to change it for testing).

I also changed <source> to have the closing /> generally required in HTML5

HTH
-- Mark
Reply all
Reply to author
Forward
0 new messages