Start a new topic

Show video through a button

Hi. I would like to know how to add a video.play() in a button.


I have the following code:

var World = {

loaded: false,

init: function initFn() {
this.createOverlays();
},

createVideoBtn: function createVideoBtnFn(imgButton, size, video) {
var Vbtn = new AR.ImageDrawable(imgButton, size, {
offsetX: -0.25,
offsetY: -0.25,
onClick : function() {
video.enabled = true,
video.play();
}
});
return Vbtn;
},


createOverlays: function createOverlaysFn() {

this.tracker = new AR.ClientTracker("assets/tracker.wtc", {
onLoaded: this.worldLoaded
});

var imgButton = new AR.ImageResource("assets/button.png");

var videourl = "assets/video.mp4";

var video = new AR.VideoDrawable(videourl, 0.40, {
offsetY: -0.3,
enabled: false,
});

var page4Button = this.createVideoBtn(imgButton, 0.45, video);

var page4 = new AR.Trackable2DObject(this.tracker, "Cocodrilo", {
drawables: {
cam: [page4Button]
}
});
},

};

World.init();


But, it doesn't work properly and it doesn't show the video, only the audio is heard.

Login or Signup to post a comment