Hi i want to do event when my youtube video ends. Event onStateChange
works on desktop and android perfect but on IOS devices doesn't do change when youtube video ends because IOS is opening youtube in build in player. Here is my javascript:
嗨我想在我的YouTube视频结束时做活动。事件onStateChange适用于桌面和Android完美但在IOS设备上不会改变youtube视频结束,因为IOS在内置播放器中打开youtube。这是我的javascript:
// create youtube player
var player;
function onYouTubePlayerAPIReady() {
player = new YT.Player('player', {
height: '340',
width: '850',
videoId: 'xnh7zOFes-4',
playerVars: {
controls: 0,
showinfo: 0,
rel: 0
},
events: {
'onStateChange': onPlayerStateChange
}
});
}
function onPlayerStateChange(event) {
if(event.data === 0) {
$('.mobile').fadeOut();
$('.newsletter').css('display','flex');
}
}
1 个解决方案
#1
0
I think your function should be called: onYouTubeIframeAPIReady():
我认为应该调用你的函数:onYouTubeIframeAPIReady():
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '340',
width: '850',
videoId: 'xnh7zOFes-4',
playerVars: {
controls: 0,
showinfo: 0,
rel: 0
},
events: {
'onStateChange': onPlayerStateChange
}
});
}
#1
0
I think your function should be called: onYouTubeIframeAPIReady():
我认为应该调用你的函数:onYouTubeIframeAPIReady():
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '340',
width: '850',
videoId: 'xnh7zOFes-4',
playerVars: {
controls: 0,
showinfo: 0,
rel: 0
},
events: {
'onStateChange': onPlayerStateChange
}
});
}