Adding audio to target image

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??

1 Like

Hello @jveszx,

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

https://docs.zap.works/studio/audio-and-video/filetype-support/

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:

image

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

image

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

image

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.

2 Likes

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

2 Likes

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.

1 Like

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

Script%20Page

2 Likes

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:

image

Option 2:

image

att, Higão.

1 Like

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

2 Likes

You Rock !!

Steve

2 Likes

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

aahhhhhhhh nevermind, i can do ittttttt finallyyyyyyy yuuhhhuuuuuuuuuuuuu

1 Like