Having trouble with simple audio macro

35 views
Skip to first unread message

Chris Fischer

unread,
Mar 16, 2020, 3:14:07 PM3/16/20
to tiddl...@googlegroups.com
Hello all,

I've been experimenting with Audio and Video macros such as those demonstrated here: http://av-macros.tiddlyspot.com/

I have a simple tiddler with a link to a local audio file. I'm trying to turn it into a macro so that if I want to change the format for an audio tiddler, I can edit the template tiddler once.

template/AudioPost:
\define AudioPost(file)
<audio controls src="$file$"/>
\end

My test tiddler:
<$set name="file" value="Audio/Evans/Evans, Tony - Revive Us Again - 08 - Are We Ready for Revival (Mt 3_1-2).mp3">
<<AudioPost>>
</$set>

<$set name="file" value="Audio/Evans/Evans%2C%20Tony%20-%20Revive%20Us%20Again%20-%2008%20-%20Are%20We%20Ready%20for%20Revival%20%28Mt%203_1-2%29.mp3">
<<AudioPost>>
</$set>

<audio controls src="Audio/Evans/Evans%2C%20Tony%20-%20Revive%20Us%20Again%20-%2008%20-%20Are%20We%20Ready%20for%20Revival%20%28Mt%203_1-2%29.mp3" />
'
Only my third version works....neither attempt to use the macro work.

Annotation 2020-03-16 151218.jpg


Any thoughts one why the audio tag in the macro isn't recognizing the file path when it's identical to the path in the explicit src?

Chris Fischer

unread,
Mar 16, 2020, 3:20:55 PM3/16/20
to TiddlyWiki
Ok, I actually solved it, but I hope someone can explain WHY.

I added parentheses:

\define AudioPost(file)
<audio controls src="$(file)$"/>
\end

Mat

unread,
Mar 16, 2020, 3:22:02 PM3/16/20
to TiddlyWiki
Yeah, you've designed the macro to expect a "file" argument but you're not providing one in the macro call. If you want it to use the "file" variable without having to include it in the call, it should say:

\define AudioPost()

<audio controls src="$(file)$"/>
\end

or simply

\define AudioPost() <audio controls src="$(file)$"/>

That was at least one major problem. I didn't test the code so there may be others but do test this and come back if problems.

<:-)

Chris Fischer

unread,
Mar 16, 2020, 3:52:43 PM3/16/20
to TiddlyWiki
Thanks! I was confusing variables with macro parameters.

I ended up going with this:

Macro def:
\define AudioPost(file)
<audio controls src="$file$"/>
\end

Macro call:
<<AudioPost file:"Audio/Evans/Evans%2C%20Tony%20-%20Revive%20Us%20Again%20-%2006%20-%20The%20Great%20God%20of%20Revival%20%281Ki%2018_20-36%29.mp3" >>

Much cleaner for my purposes than defining a variable.
Reply all
Reply to author
Forward
0 new messages