Howler.js and timeline siamese twins audio


(theron_hp) #1

Hi Everyone.

I have a strange occurrence when triggering audio with howler.js. Once I’ve played the audio connected to a timeline with a function, the audio always trigger with the timeline, although the other script does not trigger the timeline.

In my example: When you play audio first, it triggers only the audio. Once you trigger the audio and the timeline, the audio never plays without the timeline again.
I literally have to create a duplicate of the audio file and trigger it independently, which is not ideal.

Any ideas?
SiameseConnection.zip (94.0 KB)


#2

When you run this function:

CMajor.on('play', function(){
					hypeDocument.startTimelineNamed('movingBox', hypeDocument.kDirectionForward);
				});

It says if the CMajor audio element is played, run the following function. So your document is doing the correct thing: If you load the first function which plays the audio (and creates this ‘listener’) – any subsequent plays will also play the timeline when the audio is played.

Setting a condition like this is best to do ‘on scene load’ so a button press is not required. So you could set your condition (like the above) and then whenever an audio object which has a condition attached to it is played then the function will be run. If you want to play the audio and timeline (without setting the conditional listener) you would run this function for your playTimeline function:

CMajor.play();
hypeDocument.startTimelineNamed('movingBox', hypeDocument.kDirectionForward);

(theron_hp) #3

Thanks @Daniel.

So because it is a ‘listener’ and not an ‘action’, playing the sound will always trigger the listener action as well. (In layman terms.)
I will have to change the set-up of my documents in the future.
Something learned!

Regards
Herman