I have created my class, and inside it, I have an object of YouTube Iframe API and an object of ion Range Slider.
How do I make those 2 other objects interact with each other? I need iframe’s video progress to seek with the RangeSlider position change?
class VideoPlayer {
constructor(url, numItems, div) {
...
this.player = this.createPlayer(); // this way it seems that I cant refer to this.player from within RangeSlider class
this.createRangeSlider();
}
...
createRangeSlider() {
// alert(this.player.getDuration());
$(".js-range-slider").ionRangeSlider({
type: "double",
onChange: function (data) {
this.player.seekTo(data); // this.player here is unaccessible
},
});
}
createPlayer() {
let obj = new YT.Player(`player-${this.numItems}`, {
width: "640",
height: "390",
videoId: this.url,
events: {
onReady: this.onPlayerReady,
},
});
return obj;
}
...
}