Close iframe when youtube video ends

Q&A about the latest versions
Post Reply
SAwity
Posts: 32
Joined: Fri Sep 07, 2018 9:38 am

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
User avatar
Hopki
Gnome
Posts: 13018
Joined: Thu Jan 10, 2008 3:16 pm
Location: Layer de la Haye, Essex UK
Contact:

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
Garden Gnome Support
If you send an e-mail to support please send a link to the forum post for reference.
support@ggnome.com
https://ggnome.com/wiki/documentation/
SAwity
Posts: 32
Joined: Fri Sep 07, 2018 9:38 am

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>
User avatar
Hopki
Gnome
Posts: 13018
Joined: Thu Jan 10, 2008 3:16 pm
Location: Layer de la Haye, Essex UK
Contact:

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
Garden Gnome Support
If you send an e-mail to support please send a link to the forum post for reference.
support@ggnome.com
https://ggnome.com/wiki/documentation/
SAwity
Posts: 32
Joined: Fri Sep 07, 2018 9:38 am

Alright, thank you so much for the quick replies.

Regards,
Selasie
SAwity
Posts: 32
Joined: Fri Sep 07, 2018 9:38 am

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?
User avatar
Hopki
Gnome
Posts: 13018
Joined: Thu Jan 10, 2008 3:16 pm
Location: Layer de la Haye, Essex UK
Contact:

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,
Garden Gnome Support
If you send an e-mail to support please send a link to the forum post for reference.
support@ggnome.com
https://ggnome.com/wiki/documentation/
SAwity
Posts: 32
Joined: Fri Sep 07, 2018 9:38 am

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
User avatar
Hopki
Gnome
Posts: 13018
Joined: Thu Jan 10, 2008 3:16 pm
Location: Layer de la Haye, Essex UK
Contact:

HI,
Please find the project attached.
The action is in the video element.
Regards,
Attachments
Archive.zip
(1.34 MiB) Downloaded 301 times
Garden Gnome Support
If you send an e-mail to support please send a link to the forum post for reference.
support@ggnome.com
https://ggnome.com/wiki/documentation/
SAwity
Posts: 32
Joined: Fri Sep 07, 2018 9:38 am

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
Post Reply