Start a new topic

not able to stop audio sound using stop()

not able to stop audio sound using stop()

Kindly find my code sinppet

var World = {

loaded: false,

rotating: false,


init: function initFn() {

/* Disable all sensors in "IR-only" Worlds to save performance. If the property is set to true, any geo-related components (such as GeoObjects and ActionRanges) are active. If the property is set to false, any geo-related components will not be visible on the screen, and triggers will not fire.*/ = false;




createOverlays: function createOverlaysFn() {

// Initialize Tracker

this.tracker = new AR.Tracker("assets/", {

onLoaded: this.loadingStep



this.modelCar = new AR.Model("assets/car.wt3", {

onLoaded: this.loadingStep,

onClick: this.toggleAnimateModel,

scale: {

x: 0.0,

y: 0.0,

z: 0.0


translate: {

       x: 0.0,

y: 0.05,

z: 0.0


rotate: {

roll: -25



// instantiate the model object

//var model = new AR.Model("assets/boss.wt3");


// instantiate the model animation with the animation id

//var animation = new AR.ModelAnimation(model, "pPlane4_animation");


// start the animation



// Appearing Animation

this.appearingAnimation = this.createAppearingAnimation(this.modelCar, 0.045);


// Rotation Animation

//this.rotationAnimation = new AR.PropertyAnimation(this.modelCar, "rotate.roll", -10, 335, 10000,{onStart :});

this.rotationAnimation = new AR.PropertyAnimation(this.modelCar, "rotate.roll", -25, 335, 10000);


var imgRotate = new AR.ImageResource("assets/rotateButton.png");

var buttonRotate = new AR.ImageDrawable(imgRotate, 0.2, {

offsetX: 0.25,

offsetY: 0.4,

onClick: this.toggleAnimateModel



var trackable = new AR.Trackable2DObject(this.tracker, "carAd", {

drawables: {



onEnterFieldOfVision: this.appear




loadingStep: function loadingStepFn() {

if (!World.loaded && World.tracker.isLoaded() && World.modelCar.isLoaded()) {

World.loaded = true;

var cssDivLeft = " style='display: table-cell;vertical-align: middle; text-align: right; width: 50%; padding-right: 15px;'";

var cssDivRight = " style='display: table-cell;vertical-align: middle; text-align: left;'";

document.getElementById('loadingMessage').innerHTML =

"<div" + cssDivLeft + ">Scan CarAd Tracker Image:</div>" +

"<div" + cssDivRight + "><img src='assets/car.png'></img></div>";





createAppearingAnimation: function createAppearingAnimationFn(model, scale) {

var sx = new AR.PropertyAnimation(model, "scale.x", 0, scale, 1500, {



var sy = new AR.PropertyAnimation(model, "scale.y", 0, scale, 1500, {



var sz = new AR.PropertyAnimation(model, "scale.z", 0, scale, 1500, {







appear: function appearFn() {





resetModel: function resetModelFn() {


World.rotating = false;

World.modelCar.rotate.roll = -25;



toggleAnimateModel: function toggleAnimateModelFn() {

   var sound = new AR.Sound("assets/car-ignition-3.mp3");

if (!World.rotationAnimation.isRunning()) {

if (!World.rotating) {


World.rotating = true;; 

//alert("SOund played");


//alert("Sound Resume");

} else {





} else {






return false;








Thanks in advance.

i m using Phonegap starts playing the sound but dont stop


If any one have the Solution please provide it.


From a quick look at it it seems you are creating a AR.Sound each time the toggle function is called. This means that by the time you call .stop() a new sound object has been created. Since you don't keep a reference to the original there is no way to call .stop on it.

I suggest to move the creation of the Sound object to createOverlays function.

I created AR.Sound object in createOverlays function and called in toggle function

its giving error like 

03-28 09:57:15.902: E/Web Console(31492): Uncaught ReferenceError: sound is not defined at file:///android_asset/www/world/2_3dAndImageRecognition_3_Interactivity/js/imagerecognitionand3d.js:127

Kindly help


Please use the ADE included with the SDK Package (ade.js) to run your world inside a desktop browser. This allwos you to debug such javascript errors more easily. My guess here is that 'sound' is declared with in the createOverlays function and therefore is not known in the toggleAnimateModel function. 

ADE is already included den also the toggle function is not geting the ar.sound object.Kinsly help me

Thank you

Did you run it inside a desktop browser and used the debugging tools available there to fix any javascript errors?

i tried running it inside a desktop browser but its just showing me main index.html page and on click of any sample its not opening the camera to scan the marker.Kindly help me

Thank you

The ADE is just a debugging environment for your javascript code. It allows to use all functions but does not render an AR scene. However there is a text based representation of all the objects you created and you have the possiblity to call triggers by clicking on an object's trigger function. To get to this text based representation click the triangle in the bottom right corner.
Login or Signup to post a comment