Page 1 of 1

Close iframe when youtube video ends

Posted: Mon Feb 25, 2019 7:35 pm
by SAwity
Hello guys,
Im a bit stumped here..Is there a way for an iframe to close automatically when a youtube video finishes playing? Any help is greatly appreciated

Re: Close iframe when youtube video ends

Posted: Mon Feb 25, 2019 8:12 pm
by Hopki
Hi SAwity,
In short you can not.
If you hosted the MP4 on a server or a file then we can detect the length of the video, but with YouTube and Vimeo we don't get the required information to detect the end of the video.
Regards,
Hopki

Re: Close iframe when youtube video ends

Posted: Mon Feb 25, 2019 10:13 pm
by SAwity
How about this?

I read this should work at https://stackoverflow.com/questions/260 ... video-ends but i do not know how to input this into the html file. Can you please have a look? It works here http://jsfiddle.net/smvora_4u/nprgpgek/1/

<div id="player"></div>
<script src="http://www.youtube.com/player_api"></script>
<script>

// create youtube player
var player;
function onYouTubePlayerAPIReady() {
player = new YT.Player('player', {
height: '390',
width: '640',
videoId: 'XzZudNOwkU8', <!-- video id should be here. last component from video URL -->
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}

// autoplay video
function onPlayerReady(event) {
event.target.playVideo();
}

// when video ends
function onPlayerStateChange(event) {
if(event.data === 0) {
$('#player').css('display', 'none');
}
}

</script>

Re: Close iframe when youtube video ends

Posted: Mon Feb 25, 2019 11:00 pm
by Hopki
Yes I saw this but as said Pano2VR cannot.
I will add this as a feature request so it will be on the developers radar.
Regards,
Hopki

Re: Close iframe when youtube video ends

Posted: Mon Feb 25, 2019 11:19 pm
by SAwity
Alright, thank you so much for the quick replies.

Regards,
Selasie

Re: Close iframe when youtube video ends

Posted: Tue Nov 10, 2020 7:56 am
by SAwity
Hopki wrote: Mon Feb 25, 2019 11:00 pm Yes I saw this but as said Pano2VR cannot.
I will add this as a feature request so it will be on the developers radar.
Regards,
Hopki
Hello Hopki, any progress on this?

Re: Close iframe when youtube video ends

Posted: Tue Nov 10, 2020 12:50 pm
by Hopki
Hi,
Yes, the video element can detect the end of a YouTube/Vimeo video.
So you can use a Media Ended action to close, self in the video element.
Note for this to work you need to use the video element and not an iframe in a textbox.
Regards,

Re: Close iframe when youtube video ends

Posted: Thu Nov 12, 2020 6:02 am
by SAwity
Hopki wrote: Tue Nov 10, 2020 12:50 pm Hi,
Yes, the video element can detect the end of a YouTube/Vimeo video.
So you can use a Media Ended action to close, self in the video element.
Note for this to work you need to use the video element and not an iframe in a textbox.
Regards,
Hi Hopki,

Thanks again for the reply. It however did not work. I put the Media Ended action on the "popup_video_youtube" element and tried to close by changing visibility and variables, none worked.

Can you please send a sample skin with this setup working? I'm really stumped

Re: Close iframe when youtube video ends

Posted: Thu Nov 12, 2020 7:05 pm
by Hopki
HI,
Please find the project attached.
The action is in the video element.
Regards,

Re: Close iframe when youtube video ends

Posted: Sat Nov 14, 2020 8:32 am
by SAwity
Hopki wrote: Thu Nov 12, 2020 7:05 pm HI,
Please find the project attached.
The action is in the video element.
Regards,
You are a gem, Hopki! off to try this! Thank you