I am new to Framer and have only a working knowledge of Javascript.
I'm trying to create a Framer prototype using the Framer Audio Player module. It works fine for the basic situation I came up with, but now that I am trying to do something slightly more complex, I'm getting stuck.
What I'm trying to do: I would like to play one audio clip on hover. If the user keeps hovering for the duration of the audio clip, then, as soon as the first clip ends, another "success" clip should play once.
In the code below, the first clip plays fine, but the second clip keeps repeating over and over. I tried to use .once()
, by entering -- trial and error style -- various forms of 'audio.player.once "ended", ->'
and 'audio.player.play().once'
, but that approach isn't working. I couldn't find .once
in the Framer docs, either.
Here's my Framer/CoffeeScript code snippet:
mouseOver = (bool) ->
if bool
goal.animate
properties:
opacity: .5
backgroundColor: "transparent"
borderColor: "8AFFC1"
borderWidth: 3
sensor.animate
backgroundColor: "green"
options:
time: 0.25
audio.player.play() # play first clip
audio.player.loop = false
audio.player.on "ended", -> # when first clip has ended...
print "done"
audio.player.src = "success.wav"
audio.player.play() # I only want this to play once!
else
goal.animate
properties:
opacity: 1
backgroundColor: "transparent"
borderWidth: 3
borderColor: "white"
sensor.animate
backgroundColor: "red"
options:
time: 0.25
audio.player.pause()
reset = !bool
I feel like there is probably a straightforward answer here, but my limited understanding is tripping me up. Does anyone have any thoughts? Thanks!