This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
Ania Banaszek
Posted Jan 04 - Read on Facebook

Hej hello! Is there a way to add states to audio 🎶🎶🎶 files? I'm trying to recreate a simple play/pause button behaviour when on the first click, audio starts playing, icon changes to "pause", on the second click, audio stops playing, icon changes to "play" state. While I can handle the icon changes with states I can't figure out how to apply the pause state to audio.

7 Comments

Gracjan Złotucha

Hej, u can simply use sound.pause() in code :)

Ania Banaszek

Thx Gracjan! I know that sound.pause() works. What I'm struggling is, is how to apply it as a part of button state (possibly there's an easy solution but I'm still a coffee script noobie).

Ania Banaszek

Uh, if that helps. For visual changes to the button I use button.onClick -> for layer in buttonLayers / layer.stateCycle("one", "two"). Couldn't figure out how to cycle between sound.play() and sound.pause() though...

Gracjan Złotucha

Ania Banaszek https://framer.cloud/umEKk - here's the solution :) If u have any questions about this DM me.

Ania Banaszek

Gracjan <3 <3 <3 That is exactly what I was looking for! Thank you!

Joseph Brick

Hi! You can also respond to messages. This is handy when something else affects the current play state, like hitting the end of the file.

Ania Banaszek

Joseph Thank you!

Read the entire post on Facebook