Hello,
I have searched high and low and have not been able to come up with a solution to this so I am hoping the community can help. I have a simple file that has a show video button and a hide video button. When the show video button is clicked I would like an instance of the video symbol to be created that shows a youtube video. When the hide video button is clicked I would like the instance to be deleted. When the show button is clicked again it should create a new instance with the youtube video again.
I am trying to find a way of making the youtube video refresh/reload when it appears on the screen, currently when I show/hide the video symbol the movie keeps playing in the background.
**Notes** When I change "newVideo" to video in the youtube embed code the video appears when the button is clicked, and another appears below it when it is clicked again, but when I delete the "video" symbol it will not reappear when I click the show button.
Here is the code I have placed in each button:
Show Video:
var newVideo = sym.createChildSymbol("video", "Stage");
newVideo.getSymbolElement().css({
'position':'absolute',
'left':30,
'top':48
});
//code to embed youtube into symbol
var youtube = $("<iframe/>");
sym.$("newVideo").append(youtube);
youtube.attr('type', 'text/html');
youtube.attr('width', '640');
youtube.attr('height', '360');
youtube.attr('src', 'https://www.youtube.com/embed/MyFv6UKsW70?rel=0');
youtube.attr('frameborder', '1');
youtube.attr('allowfullscreen', '0');
Hide Video:
sym.getSymbol("newVideo").deleteSymbol();
Here is a link to my project zip:
http://www.capitalpress.biz/html5ads/youtube/CreateDeleteYoutube.zip
Thank you for your help!
Brandon