I dont know a lot of javascript but I wonder if this is possible:
I need the videos to be invisible and when I press one of my links a youtube embed fades in (and starts playing). Then when I mouseOver and mouseOut I want it to fade out and then be able to fade in again on mouseOver, but I don't get it to work. I've had different results where the div seems to disappear (when I mouse over where the player used to be nothing fades in) and now im stuck at this:
Here is how far I've come with looking around here on stackoverflow for solutions:
Here's a jsFiddle > http://jsfiddle.net/VKzxy/
And my jQuery:
/* elt: Optionally, a HTMLIFrameElement. This frame's video will be played,
* if possible. Other videos will be paused*/
function playVideoAndPauseOthers(frame) {
$('iframe[src*="http://www.youtube.com/embed/"]').each(function(i) {
var func = this === frame ? 'playVideo' : 'pauseVideo';
this.contentWindow.postMessage('{"event":"command","func":"' + func + '","args":""}', '*');
});
}
$('#links a[href^="#vid"]').click(function() {
var frameId = /#vid(\d+)/.exec($(this).attr('href'));
if (frameId !== null) {
frameId = frameId[1]; // Get frameId
playVideoAndPauseOthers($('#playlist' + frameId + ' iframe')[0]);
$($('#playlist' + frameId + ' iframe')[0]).fadeIn(750);
//When hovering, fadeIn.
$('#content').mouseenter(function(){
$($('#playlist' + frameId)[0]).fadeIn(750);
});
//When leaving, fadeOut.
$($('#playlist' + frameId)[0]).mouseleave(function(){
$($('#playlist' + frameId)[0]).fadeOut(750);
});
}
});
edit: It does not have to be in javascript, any solution that works will be fine.