Hi John:
I got it to work!
I altered a fade file from my own website.
Test Page
Working 4 state on/off fade code:
Code:
<script type="text/javascript">
var hoverFadeTime = 900;
var clickFadeTime = 900;
var hoverFade = true;
function crossFade(el, url, c) {
if(!c || hoverFade) {
if(el.css("background-image").indexOf(url) == -1) {
var ap = $("<button type=\"button\" class=\"play\"></button>").css({
"position": "absolute",
"left": el.position().left,
"top": el.position().top,
"z-index": -1,
"background-image": el.css("background-image")
});
el.after(ap).css("background-image", "url(\"" + url + "\")")
el.hide().fadeIn((c ? hoverFadeTime : clickFadeTime), function() {
ap.remove();
});
if(c) {
ap.fadeOut((c ? hoverFadeTime : clickFadeTime));
}
}
} else {
el.css("background-image", "url(\"" + url + "\")");
}
}
$(".play").click(function() {
var parent = $(this);
var child = parent.children()[0];
if(child.paused) {
$(".play > audio").each(function() {
if(!this.paused) {
crossFade($(this).parent(), "images/music-off.png");
this.pause();
this.currentTime = 0;
}
});
crossFade(parent, "images/music-off.png");
child.play();
} else {
crossFade(parent, "images/music-on.png");
child.pause();
child.currentTime = 0;
}
}).mouseover(function() {
var parent = $(this);
if(parent.css("opacity") == 1) {
if(parent.children()[0].paused) {
crossFade(parent, "images/music-on-over.png", 1);
} else {
crossFade(parent, "images/music-off-over.png", 1);
}
}
}).mouseout(function() {
var parent = $(this);
//setTimeout(function() {
if(parent.children()[0].paused) {
crossFade(parent, "images/music-on.png", 1);
} else {
crossFade(parent, "images/music-off.png", 1);
}
});
</script>
<div class="style1">
<button type="button" id="mute" src="images/music-off.png" class="play"/><audio id="audio" preload="auto" tabindex="0" type="audio/mpeg"></audio></button>
</div>
Bookmarks