contact@zeanex.com
+92 (317) 4843 022
Get a Quote
  • Home
  • Company
  • Products
  • Services
    • Marker based AR
    • Cloud based AR
  • Help & Support
    • Contact Us
    • FAQ
  • Blog

No products in the cart.

  • Home
  • Company
  • Products
  • Services
    • Marker based AR
    • Cloud based AR
  • Help & Support
    • Contact Us
    • FAQ
  • Blog

No products in the cart.

  • Home
  • Company
  • Products
  • Services
    • Marker based AR
    • Cloud based AR
  • Help & Support
    • Contact Us
    • FAQ
  • Blog

No products in the cart.

  • Home
  • Company
  • Products
  • Services
    • Marker based AR
    • Cloud based AR
  • Help & Support
    • Contact Us
    • FAQ
  • Blog
Blog
Home Tutorials play audio on an image target using vuforia in unity 3d
Tutorials

play audio on an image target using vuforia in unity 3d

CEO October 9, 2019 0 Comments

In real world to augment virtual objects augmented reality is used. In this tutorial you will learn to Play audio on an image target using vuforia in unity 3D. The video below will help you for better understanding of this blog.

For better understanding make sure to read the previous blogs i.e. DISPLAY 3D MODEL ON IMAGE TARGET USING VUFORIA IN UNITY3D ,DISPLAY IMAGE ON AN IMAGE TARGET OR MARKER USING VUFORIA and DISPLAY VIDEO ON AN IMAGE TARGET OR MARKER USING VUFORIA IN UNITY 3D.

Create a new unity project:

In augmented reality creating a new unity project requires some of the things to be done. For creating a new unity project you need to write project name and then click on create project.

Creating database

Adding new image:

For adding a new image target you need to go to vuforia engine. After going to vuforia engine click on image and re position it. Now go to vuforia portal. For opening vuforia developer portal make sure that you are sign in. Click on develop and after that go to click on target manager. For adding the target click on single image. Now choose the image by clicking on the browse button, then add certain width and rename it. Then click on add.

Adding target

Scene Setting:

Now we have to set scene for augmented reality. For that you have to delete main camera and add AR camera and image. As you can see this warning sign, go to build settings then go to player settings. Go to the bottom click on XR settings and check the vuforia augmented reality.

Warning sign during scene setting

Downloading the database:

Now download that data base. Click on unity editor then click on download. When it is downloaded drag it to the unity timeline put it in assets. Make sure that all the items are selected and click on import. Go to image target and select your database. Now you can see your image has loaded.

Downloading Database

Importing the audio clip:

Now as we want to play audio on an image target. Go to audio and then audio source. Let’s import it in unity first and drag this into the audio clip section.

Audio
clip  importing

Playing the audio:

We want to play the audio only when the image target is visible. So unchecked the play on awake. If you want to loop the audio means you want to play the audio again and again when it ends. So, check the loop checkbox. We want to play audio only when the target image is found and we want to stop the audio when the image target is lost.

Coding of track able event handler:

The code of this track able event handler file is totally same as to the default track able event handler file that is attached to our image target. We will open this file. We only have to do few minor changing in code. Press Ctrl A and then Ctrl C and paste it to the track able event handler file.

Now in the track able event handler file delete the default placed code and press Ctrl V to paste the default track able event handler code in this file. Coding of track able event handler:heck the name of the file which is track able event handler file and give the same name to the class.

Adding unity engine event:

So, basically what we have to change in this file is that we are going to add unity engine event. So, we will be using codes as:

using Unity Engine. Events;

Declaring public variables:

We need to declare two public variables onTrack and onLost.

public UnityEvent onTrack;

public UnityEvent onLost;

Unity events
Declaring unity events

The event onTrack needs to be called when tracking is found. So, here we will write

onTrack.Invoke();

The second unity event onLost needs to be called when tracker is lost. So, here we will write

onLost.Invoke();

Play, stop and pause audio:

Save the file. Now attach this code to the image target and delete the default attached component. After that you will see the two events which are the public events that we have initialized onTrack and onLost. Click on the + icon in onTrack event. Here onTrack event drag the audio source. OnTrack we want to play the audio, audio source.play() and onLost repeat the same steps. Drag the audio source and go to audio source.pause() or audio source.stop().

Adding audio in unity

Export Application :

From top menu click on file, then click on build settings. Check the platform is android if not switch it. And then click on add open scenes. Now click on player settings. Go to other settings. Change the package name according to your choice. Unchecked x86 and Android TV compatibility. Change the stripping level to low. Click on XR settings and make sure vuforia augmented reality is selected. And then you can insert the icon of your app. That’s all for settings now connect your android mobile with your computer and click on build and run. Now name it and save it.

Eating for the Bodybuilding Physique of the 70s anavar pills review old school bodybuilding workout | old school labs
Augmented reality Play audio on an image target unity3d vuforia
0
2118 Views
AboutSundas Fatima
Display Video on an image target using VUFORIA in unity 3dPrevDisplay Video on an image target using VUFORIA in unity 3dOctober 2, 2019
display text on an image target using vuforia in unity 3dOctober 12, 2019display text on an image target using vuforia in unity 3dNext

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts
  • Augmented Reality in Ecommerce and Retail
  • Create AR for the travel and tourism industry
  • Create augmented reality experience for restaurants
  • How to install Location Based ar APP With admin panel
  • Vuforia web services api: how to add target in vuforia cloud database?
Recent Comments
  • Valéria Gomes on MarkerLess Web AR with Admin Panel
  • Greg K on Vuforia Cloud Recognition App with Web Panel
  • Mohammad on Vuforia Cloud Recognition App with Web Panel
  • Ali Hamza on Vuforia Cloud Recognition App with Web Panel
  • Ahmet on Vuforia Cloud Recognition App with Web Panel
Archives
  • September 2022
  • January 2021
  • April 2020
  • March 2020
  • February 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
Categories
  • AR Creato
Meta
  • Register
  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
Categories
  • AR Creato 3
Recent Posts
No posts were found for display
Tags
AR AR Creato arcreato AR Creator AR Editor areditor Augmented reality augmented reality in ecommerce augmented reality in restaurants Augmented Reality in Retail menu AR tourism AR travel AR

We are here to transform your ideas into reality. We can build AR applications for business, artists, education etc with custom requirements.
Services
Marker Based AR
Cloud Based AR
Contacts
Email:
contact@zeanex.com
Phone:
+92 (317) 4843 022

Newsletter

Terms of use | Privacy Policy

Copyright © 2020 Zeanex Techonologies (SMC-PVT) Limited. All Rights Reserved.