Dynamically switching VideoDrawable to be displayed
M
Markus Broelemann
started a topic
almost 6 years ago
Hi everyone,
I am currently trying to achieve something akin to a "language selection". At the start, two ImageDrawables displaying the flag of a certain language are displayed. Clicking one of the images fires the "selectLanguage" function in my code, which tries to remove the ImageDrawables and add the correct VideoDrawable to the view. This is what it looks like:
var World = {
init: function initFn() {
this.createOverlays();
},
createOverlays: function createOverlaysFn() {
this.targetCollectionResource = new AR.TargetCollectionResource("assets/tracker.wtc");
this.tracker = new AR.ImageTracker(this.targetCollectionResource);
var video;
var irLangDE = new AR.ImageResource("assets/langDE.png");
var irLangENG = new AR.ImageResource("assets/langENG.png");
this.drawLangDE = new AR.ImageDrawable(irLangDE, 0.25, {
onClick: function () {
selectLanguage(0);
},
offsetX: -0.25
});
this.drawLangENG = new AR.ImageDrawable(irLangENG, 0.25, {
onClick: function () {
selectLanguage(1);
},
offsetX: 0.25
});
var trackable = new AR.ImageTrackable(this.tracker, "test", {
drawables: {
cam: [this.drawLangDE, this.drawLangENG]
}
});
}
};
function selectLanguage(i) {
switch (i) {
case 0:
World.video = new AR.VideoDrawable("assets/TestDE.mp4", 1);
break;
case 1:
World.video = new AR.VideoDrawable("assets/TestENG.mp4", 1);
break;
default:
World.video = new AR.VideoDrawable("assets/TestDE.mp4", 1);
}
trackable.drawables.removeCamDrawable(World.drawLangDE);
trackable.drawables.removeCamDrawable(World.drawLangENG);
trackable.drawables.addCamDrawable(World.video);
World.video.play();
};
World.init();
Everything about this works until I try to remove the drawables or add the video to it. How would I go about doing this instead? Am I just referencing something from the wrong place in JavaScript?
Any help is appreciated.
Best regards
Markus
1 Comment
Wikitude Support
said
almost 6 years ago
Hello Markus,
Maybe the following forum posts can help you with your use case:
Markus Broelemann
Hi everyone,
I am currently trying to achieve something akin to a "language selection". At the start, two ImageDrawables displaying the flag of a certain language are displayed. Clicking one of the images fires the "selectLanguage" function in my code, which tries to remove the ImageDrawables and add the correct VideoDrawable to the view. This is what it looks like:
Everything about this works until I try to remove the drawables or add the video to it. How would I go about doing this instead? Am I just referencing something from the wrong place in JavaScript?
Any help is appreciated.
Best regards
Markus