Close iframe when youtube video ends

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

Mon Feb 25, 2019 7:35 pm

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: 10831
Joined: Thu Jan 10, 2008 3:16 pm
Location: Layer de la Haye, Essex UK
Contact:

Mon Feb 25, 2019 8:12 pm

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
Hopki
Garden Gnome Software 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: 25
Joined: Fri Sep 07, 2018 9:38 am

Mon Feb 25, 2019 10:13 pm

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: 10831
Joined: Thu Jan 10, 2008 3:16 pm
Location: Layer de la Haye, Essex UK
Contact:

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
Hopki
Garden Gnome Software 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: 25
Joined: Fri Sep 07, 2018 9:38 am

Mon Feb 25, 2019 11:19 pm

Alright, thank you so much for the quick replies.

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

Tue Nov 10, 2020 7:56 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: 10831
Joined: Thu Jan 10, 2008 3:16 pm
Location: Layer de la Haye, Essex UK
Contact:

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,
Hopki
Garden Gnome Software 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: 25
Joined: Fri Sep 07, 2018 9:38 am

Thu Nov 12, 2020 6:02 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: 10831
Joined: Thu Jan 10, 2008 3:16 pm
Location: Layer de la Haye, Essex UK
Contact:

Thu Nov 12, 2020 7:05 pm

HI,
Please find the project attached.
The action is in the video element.
Regards,
Attachments
Archive.zip
(1.34 MiB) Downloaded 7 times
Hopki
Garden Gnome Software 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: 25
Joined: Fri Sep 07, 2018 9:38 am

Sat Nov 14, 2020 8:32 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