I'm building a slide presentation with audio, using jPlayer. I want lines of text to appear based on the current time. Each line is wrapped in a div, hidden and given a class. I've added in and out attr to the divs. Here is the code I have so far:
<script type="text/javascript">
$(function() {
$("#jquery_jplayer_1").jPlayer( {
ready: function () {
$(this).jPlayer("setMedia", {
mp3: "media/audio.mp3",
oga: "media/audio.ogg"
}).jPlayer("play");
},
supplied: "mp3, oga",
swfPath: "js"
});
$("#jquery_jplayer_1").bind($.jPlayer.event.timeupdate, function(event) {
currentTime = Math.floor(event.jPlayer.status.currentTime)
var slidesdiv = $('#slides');
// Hides all slides to start
$(slidesdiv).children().addClass('starthidden');
// stores the number of slides
var numslides = $(slidesdiv).children().length;
// adds slidexx class to each div
$('#slides > div').addClass(function() {
return 'slide' + $(this).index();
});
if (currentTime >= $('#slides > div').attr('in') && currentTime < $('#slides > div').attr('out')) {
$('#slides > div').fadeIn("fast");
} else {
$('#slides > div').fadeOut("fast");
}
});
});
</script>
and the html:
<div id="slides">
<!-- Slide 1 -->
<div in="1" out="3"><h2>Implications</h2></div>
<div in="5" out="8">Implications have the form</div>
etc..
</div>
I've gotten pretty close, and the whole #slides appears at 1sec, disappears at 3sec, but I need only the first div to come go, then move on to the next div and it's in/out times. Can anyone help?
Thanks, S
This script might help you a bit: