So I have embedded a vimeo video in my Angular 8 app and am now trying to trigger some animation after the video starts playing and once its ended.
(因此,我已在Angular 8应用程序中嵌入了一个vimeo视频,现在尝试在视频开始播放并结束后触发一些动画。)
Essentially if screen width is <800
, the variable isMobile
is true
. (本质上,如果屏幕宽度<800
,则变量isMobile
为true
。)
Next I have the vimeo play
method being called which checks if isMobile
is true
, and sets load_completed
(which is the animation trigger) to true
. (接下来,调用load_completed
play
方法,该方法检查isMobile
是否为true
,并将load_completed
(这是动画触发器)设置为true
。)
The isssue is that my variable isMobile
returns undefined
, why is that? (问题是我的变量isMobile
返回undefined
,为什么呢?)
isMobile = false; constructor() { } ngOnInit() { this.innerWidth = window.innerWidth; console.log(this.innerWidth); if (this.innerWidth < 800) { this.isMobile = true; } var iframe = document.querySelector('iframe'); var player = new Vimeo.Player(iframe); player.on('play', function() { //isMobile returns undefined why? console.log(this.isMobile); if (this.isMobile) { this.load_completed = true; } console.log('Played the video'); }); player.on('ended', function(data) { console.log('Video ended'); }); }
ask by kontenurban translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…