How do I trigger music based on what a random selector lands on?
I'm creating a "which ___ are you?" filter for the release of my EP this Friday. It's five songs, so I thought I'd make a Snapchat filter to heighten engagement!
I already have the random selector set up so that whenever you open your mouth it lands on one of the five songs, but what I want to do is play a 10-second snippet of the corresponding song once it lands. Any idea on how to do this with scripting?
Thanks!
Hi Ryan!
That's a great idea, I can't wait to see it.
What you can do is set up a behavior script:
And then in the ImageRandomizer script, you can add a line to call this:
and each behavior script trigger will correlate to the image.
So the first image will play
and the second image will play
Let me know if you need any clarification.
Thanks!
Jonathan
Hey!
I think I'm almost getting the hang of it, haha. I'm very very very new to scripting and the project file is originally a template created by another user where all you have to do is put images in to randomize.
So, essentially, I'm digging myself into unknown territory here, so I appreciate the help.
Question - do I have to create a different behavior script for each song to correlate with? Or how does it work? How/where do I import each song to correlate properly?
Thanks,
Ryan
Hi Ryan,
Awesome!
Ya, each behavior script should control each song so that you can call that behavior script to play the song.
In the example above, you can see:
which means that the script will try to call the behavior play_song_ with curIndex appended to the end. CurIndex represents the order of the image in the ImageRandomizer script.
So for the first song for the first image, call the custom trigger in Behavior: play_song_0. The next one play_song_1, and so forth.
By the way, I am referring to this: https://support.lensstudio.snapchat.com/hc/en-us/community/posts/360055891792--Example-Project-Rotate-Through-Random-Images example project.
Cheers!
Jonathan
Hi Jonathan!
I have a question. How to change Tap Trigger to be Mouth Opened Trigger? I have tried to play with scripting but still can't change anything :(
I hope you can help me. Thanks
Hi Ryan,
Can you clarify where you want to change it?
In general you can trigger things using Behavior:
https://lensstudio.snapchat.com/guides/scripting/helper-scripts/behavior/
Or if you are using a script, you can use the "MouthOpenedEvent" key rather than the "TouchStartEvent" key:
https://lensstudio.snapchat.com/api/classes/MouthOpenedEvent/
Thanks again,
Jonathan
Hi!
in the example project that you provided. The trigger used is a tap to start the randomization of the image. what if I change it to randomization starting after I start recording for three seconds like "Guess the Gibberish" project.
I already changed the script but it didn't works :(
Regards,
Ryan
Thanks Jonathan Solichin, works wall!!
how can I mute the Mic and record the sound in the lens when I make a video?