Hiding YouTube

gideonwilliams
08 Feb 2012, 00:14
Hi Alex

Have a youtube clip linked to an object called Ch1 on a TV. When I press Ch1 the youtube clips shows (static).

Is there anyway of hiding the Youtube clip after it has played?

Cheers

Gideon

Alex
08 Feb 2012, 11:30
It would be possible with a bit of Javascript.

According to http://code.google.com/apis/youtube/js_ ... rence.html there is an event that is triggered when playback ends - this could be used to hide a <div> element containing the embedded video.

If I get a spare moment I will have a play and see if I can come up with a little library to add this function to a game (unless anybody else here would like to have a go :))

Alex
09 Feb 2012, 16:33
Well that took a bit longer than I thought, but got there in the end. Inside this zip file...


...you will find three files.

youtube test.aslx: Demo file. Play this in Quest, and type TEST. It will play the THX theme from YouTube, and hide it after 20 seconds.

To use this yourself, copy the other two files (youtubehide.aslx and youtube.js) into the same folder as the game you're working on. Then load your game in the Editor.

Add the library by going to the Add menu, then Advanced, Library. Select "youtubehide.aslx" from the drop-down, then close and re-load your game in the Editor.

When you add a script command, you'll now have a new option at the bottom of the Output category - "Play YouTube video and hide".

It works much the same as the usual "Play YouTube video" function, but it lets you specify to hide it after a certain number of seconds. (I looked into making it automatically hide when playback was finished using the YouTube API, but couldn't get it to work)

gideonwilliams
06 Jun 2012, 08:40
So remiss of me not getting back to you with my thanks for this Alex.

Awesome!


Gid