Cycle with YT Test
by waffl
HTML
<script src="http://cloud.github.com/downloads/malsup/cycle/jquery.cycle.all.2.72.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
<div id="slideshow-wrapper">
<div id="slideshow">
<img src="http://placehold.it/540x375" />
<img src="http://placehold.it/540x375/ff0000" />
<div id="ytapiplayer">You need Flash player 8+ and JavaScript enabled to view this video.</div>
</div>
<div id="prev"></div>
<div id="next"></div>
</div>
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
CSS
#slideshow-wrapper {
height: 375px;
width: 540px;
overflow: none;
position: relative;
}
#prev, #next {
height: 375px;
width: 8px;
background: #1926A5;
position: absolute;
z-index: 100;
}
#prev {
top: 0;
left: 0;
}
#next {
top: 0;
right: 0;
}
#slideshow {
height: 375px;
width: 540px;
overflow: none;
position: relative;
}
#ytapiplayer {
position: absolute;
top: 0;
left: 0;
z-index: -1;
}
p {
margin: 10px 0;
}
JavaScript
$(document).ready(function() {
$('#slideshow').cycle({
fx: 'fade',
timeout: 5000,
next: '#next',
prev: '#prev'
});
$('iframe').each(function() {
var url = $(this).attr("src");
$(this).attr("src", url + "?wmode=transparent");
});
var params = {
allowScriptAccess: "always",
wmode: "transparent"
};
var atts = {
id: "myytplayer"
};
swfobject.embedSWF("http://www.youtube.com/e/SN8VL9augCg?enablejsapi=1&playerapiid=ytplayer", "ytapiplayer", "540", "375", "8", null, null, params, atts);
function onYouTubePlayerReady(playerId) {
ytplayer = document.getElementById("ytplayer");
ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
}
function onytplayerStateChange(newState) {
$('#slideshow').cycle('pause');
alert("Player's new state: " + newState);
}
});