0 votes
by (310 points)
edited by

I'm using the Harlowe Audio Library: https://twinelab.net/harlowe-audio/#/

Hi, all, Don't meant to be abrupt and sorry if question is in wrong format since I'm fairly knew to all of this, but I encountered some problems when trying to play audio that I've loaded in already.

I'm using a startup passage with this in it: (links/names edited out for simplicity, the links do work as far as I know)

A.newTrack('soundfile', 'https://link.mp3');

And this is how the library guide says to play a sound when you click on a link:

(link: 'Exciting Link')[
    (goto: 'some passage')


Could someone help decipher this for me, and tell me how I should format this when my passages containing links look like this?:

(live: 3s)[(t8n:"dissolve")+(t8n-time: 3s)+(colour: black)[not link text [[link text->where link goes]]not link text"](stop:)]

 I'm sorry if I'm asking to be spoon-fed, but like I said I'm really new to all of this and my JS knowledge is limited at best.

The only issue that I can think of is that the <script> elements all occur when the passage is "finished", but I've tried waiting for this to no avail.


Thanks a bunch. :)

1 Answer

+1 vote
by (159k points)

There are two main types of Passage Transition links:

1. Markup based links.

[[Link Text->Target Passage Name]]
[[Target Passage Name<-Link Text]]

2. Macro based links.

This second type comes in two main sub-types:

2a. Those that include the Target Passage Name

(link-goto: "Link Text", "Target Passage Name")

2b. Those that require the usage of the (go-to:) macro to indicate the Target Passage Name.

(link: "Link Text")[
    (go-to: "Target Passage Name")


|link>[Link Text]
(click: ?link)[
    (go-to: "Target Passage Name")

The "to play a sound when you click on a link" example is an instance of 2b which also includes code to play a some audio.

To convert your [[link text->where link goes]] link example into one that also plays some audio you would do the following.

(link: "link text")[
	(go-to: "where link goes")

note: I have added line-breaks & indentation to make the above more readable, these can be safely removed.

So an updated version of your (live:) macro based example might look something like the following.


(live: 3s)[\
	(append: ?output)[\
		(t8n: "dissolve") + (t8n-time: 3s) + (colour: black)[\
			not link text \
			(link: "link text")[
				(go-to: "where link goes")
			] \
			not link text"]\

You may of noticed that I have made some additional changes to you original example:

1. It is a good idea to stop the timers created by the (live:) macro as soon as possible, thus why I moved the (stop:) macro to the start of the associated hook.

2. It can be difficult to control the exact placement & layout of content generated by a (live:) macro, thus why I used an (append:) macro to inject the generated content into a named hook. This technique also has the added advantage of reducing the HTML structure depth of your page.

3. I used Escaped Link-break markup and line-breaks & indentation to make the code a little more readable.

by (310 points)
Thanks, this worked perfectly. I also realised that, despite what I said, my link didn't work. It actually tried to take me to the website editor where I'm hosting the sounds. I fixed that issue (which I didn't notice until I restarted my computer) and also removed some of the slashes in your script, which appeared as text in the passage.


Again, thanks a bunch!