Created
December 13, 2012 16:44
-
-
Save whitperson/4277811 to your computer and use it in GitHub Desktop.
possible option for jPlayer fade-in/fade-out
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var vol = 20; | |
var t = 0; | |
function playSample(id) { | |
$("#player").stop(); | |
vol = 20; | |
stopSample(); | |
$("#player").setFile("yourfile.mp3"); | |
fadeIn(); | |
$("#player").play(); | |
} | |
function stopSample(id, fadeout) { | |
clearTimeout(t); | |
//Set fadeout = true in the function call: <a href="#" onClick="stopSample(23, true);">Stop</a> | |
if(fadeout == true) {fadeOut();} | |
} | |
$("#player").jPlayer({ | |
swfPath: "swfpath"; | |
}); | |
$("#player").onSoundComplete(function() { | |
stopSample(); | |
}); | |
function fadeIn() { | |
if(vol < 150) { | |
$("#player").volume(vol); | |
t = setTimeout("fadeIn()", 200); | |
vol = vol + 10; | |
} else { | |
clearTimeout(t); | |
vol = 150; | |
} | |
} | |
function fadeOut() { | |
if(vol > 0) { | |
$("#player").volume(vol); | |
t = setTimeout("fadeOut()", 200); | |
vol = vol - 10; | |
} else { | |
clearTimeout(t); | |
$("#player").stop(); | |
vol = 20; | |
} | |
} | |
$("#player").onProgressChange(function (l,pr,pa,pt,t) { | |
if(pa > 90 && pa < 92) { | |
stopSample(0, true); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment