Start a new topic

Video not start and show when the GEOObject already in vision field after video loaded

SDK:Android Javascript SDK

I use the example code with a little changes:

var World = {

 loaded: false,

 rotating: false,


 init: function initFn() {




 createModelAtLocation: function createModelAtLocationFn() {



   First a location where the model should be displayed will be defined. This location will be relativ to the user.


  // var location = new AR.RelativeLocation(null, 5, 0, -0.5);


        var location = new AR.RelativeLocation(null, 5, 0, -2);

        this.startVideo = new AR.VideoDrawable("assets/transparentVideo.mp4", 0.7, {

            offsetX: 0,

            offsetY: 0,

            scale: 15,

            isTransparent: true,


            onClick:function () {

                showTestMsg("click the video");






   Next the model object is loaded.



        this.modelEarth = new AR.Model("assets/earth.wt3", {

            onLoaded: this.worldLoaded,

            scale: {

                x: 0.8,

                y: 0.8,

                z: 0.8


            rotate: {

                roll: 0.0,

                tilt: 0.0,

                heading: 0.0


            translate: {

                x: 1.5,

                y: 0.5,

                z: 0


            // onClick: this.onEarthClick

   onClick:function () {




        this.rotateAnimation = new AR.PropertyAnimation(this.modelEarth, "rotate.heading", 0, 360, 8000);




        var indicatorImage = new AR.ImageResource("assets/indi.png");


        var indicatorDrawable = new AR.ImageDrawable(indicatorImage, 0.1, {

            verticalAnchor: AR.CONST.VERTICAL_ANCHOR.TOP




   Putting it all together the location and 3D model is added to an AR.GeoObject.


  var obj = new AR.GeoObject(location, {

            drawables: {

               cam: [this.modelEarth, this.startVideo],

                // cam: [this.startVideo],

               indicator: [indicatorDrawable]


            onEnterFieldOfVision: this.enter,

            onExitFieldOfVision: this.exit







 worldLoaded: function worldLoadedFn() {

  World.loaded = true;

  // var e = document.getElementById('loadingMessage');

  // // e.parentElement.removeChild(e);





 enter:function enterFn() {

        showTestMsg("geoobject enter");

        if (!World.isPlaying){


            World.isPlaying = true;

        }else {






    exit:function exitFn() {

        showTestMsg("geoobject exit");



    videoFinished:function videoFinishedFn() {

        World.isPlaying = false;

        showTestMsg("video is finished");




function showTestMsg(argument) {

    // body...








If I change the start to the onLoaded function of videoDrawble,I must judge whether the video is in vision field when it is loaded.But sometimes the indicatorDrawable is visible ,it means that the geoobject is out of vision field ,but the geoobject.isVisible  return true.

Hi He,

As you already mentioned, video drawables start playback as soon as the `play()` function was called and the video is loaded. It does not take into account if it's associated ARObject is currently visible. This is something you need to make sure by e.g. call `play()` in the onEnterFieldOfVision callback and `stop()` or `pause()` in the onExitFiedOfVision.

Regarding your update from January 13th: I assume this is a separate issue that you wanted to report? And this report is that the `isVisible` property of AR.GeoObject returns true although it's onExitFieldOfVision trigger was called and not followed by a call to the onEnterFieldOfVision callback?

Best regards,


Yes, I am sure I called the 'play()' in the onEnterFieldOfVision callback and `stop()` or `pause()` in the onExitFiedOfVision.

But if the GeoObject is allready in the vision at the moment the video loaded,the onEnterFieldOfVision can not be called.

My goal is the video can auto play after it is loaded.But it can't be achived because the onEnterFieldOfVision not called,so the 'play()' not called too.

So I judged the 'isVisible' of GeoObject in the 'loaded()' function of VideoDrawble object.

That is truely separeate issue.And I found the 'isVisible' property of AR.GeoObject is not correct.I have move my phone after open the AR page, to make the GeoObject is not in the vision when the video is loaded.Then the onExitFieldOfVision and onEnterFieldOfVision  triggers were neither called,and the indicatorDrawable is visible ,but geoobject.isVisible return true.

Hi He,

I will investigate the behaviour of the `isVisible` property.

Meanwhile you could add a new property to your `World` object and set this one to `true` in case the onEnterFieldOfVision trigger is called and to `false` when the onExitFieldOfVision trigger is called. Then in the `onLoaded` callback of the video drawable, you can evaluate this new property and e.g. start video playback if the property is set to true. 

You can define another property which stores the video drawable loaded state and use this one to determine if you can start video playback in the onEnterFieldOfVision callback.

Best regards,


Maybe I haven't describe it clearly.The most important problem is that the onEnterFieldOfVision trigger not called if the GEOObject is already in vision when I open the AR page and loaded the resource.

In this case,I must move my phone to another direction and then move back,the onEnterFieldOfVision trigger will be trigger.

Hi He,

I did some tests the last couple of days and found the following:

- onEnterFieldOfVision trigger fire for me when the device is oriented into the direction where the augmentation is placed at application launch. If you continue having problems with this, please remove all code except of the location, a simple drawable and the geo object and try it again with this minimalistic setup.

- isVisible: There was indeed a problem when AR.RelativeLocations were used. You can download a Android JS example app here(iOSAndroid) which contains an updated SDK. 

Please let me know how this build is working for you.

Best regards,


Login or Signup to post a comment