Adding audio to target image


#1

Hi there.

I am a complete beginner here and looking to use AR for an upcoming school project. I’m facing some problems with having to attach audio or have it play when a target image has been scan and an image pops out.

Basically, I wanted to incorporate the image together with audio. I have tried reading the tutorials but still unable to get it done. Am I doing something wrong??


Buttons to trigger audio
#2

Hello @jveszx,

First of everything, your sound file has to respect some specs for the plataform. You may check it out by the link:

But basically you need to has an ogg audio format. If it is mp3, mp4 or etc, won’t work in the plataform.

After this, you throw your audio in the media library section like this:

Then you throw your audio in the hierarchy area, like this:

To code you it, you may do some very basic codes. Like this:

If you want to start an audio or video in start of any experience, always use the “show” event block.

Also, you may check the codes by this link:

https://docs.zap.works/studio/scripting/reference/audio/

Hope this helps you.

att, Higão.


#3

Hi Higao,

Thank you for this. Have tried it and it works.

Is there a code that I need to put in to make the audio come together with a picture. right now, after I scan the zapcode the audio immediately comes on rather than scanning the targeted image


#4

Your image appears only when you point to the tracking image? If is this, you may try this:

Tracking_pngzpt.on("seen", ()=>{
    symbol.nodes.Sound_Test_ogg.start();
});

If you do it, when you point to the tracking image, the audio will be playing.
att, Higão.


#5

Hi is it like this as seen below? Understand I’m suppose to rename Tracking_pngzpt.on(“seen”, ()=>{


#6

Hey @jveszx,

No, no. Not ecxatly. I didn’t understand when your image will appear. There are two options:

1 - The Image will show right after the code load;
2 - The image will show only when you first point to the tracking;

If the image will do the 1 option way, your sound needs to be in “show” block. If the image will do the 2 option, your sound needs to be in the “seen” block.

Option 1:

Option 2:

att, Higão.


#7

THANK YOU SOOO MUCH HIGAO.

Tried your method and it turn out exactly how I wanted. You have really been a life saver. Thank you soooo much.

Regard,
Jarren


#8

You Rock !!

Steve


#9

hi, i didnt figure it out, my model is a 3d, and when i scan the code and pointing to the tracking, it shown my 3d object only, but the audio dint come out :’ please help me, my script is exacly same as the examples u gave


#10

aahhhhhhhh nevermind, i can do ittttttt finallyyyyyyy yuuhhhuuuuuuuuuuuuu