Skip to content

Instantly share code, notes, and snippets.

@John2496
Created September 20, 2012 17:06
Show Gist options
  • Save John2496/3757093 to your computer and use it in GitHub Desktop.
Save John2496/3757093 to your computer and use it in GitHub Desktop.
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="js/jplayer/jquery.jplayer.min.js"></script>
<script>
saveCard = function(params, callback) {
callback = typeof callback == 'function' ? callback : function() { };
params.method = 'saveCard';
$.ajax({
url : 'scripts/api.php',
data : params,
dataType : 'json',
success : callback,
error : callback
})
}
saveCard({
animal : "ANIMAL",
style : "STYLE",
mood : "MOOD",
caption : "CAPTION",
message : "MESSAGE",
friend_fb_user_id : "ID",
fb_access_token : FB.getAccessToken()
})
saveCard({
animal : animalVar,
style : styleVar,
mood : "MOOD",
caption : "CAPTION",
message : "MESSAGE",
friend_fb_user_id : "ID",
fb_access_token : FB.getAccessToken()
})
</script>
</head>
<body>
<div id="jplayer"></div>
<script>
$('#jplayer').jPlayer({
ready : function () {
},
timeupdate : function(event) {
},
play : function(event) {
},
pause : function(event) {
},
ended : function(event) {
},
swfPath : "js/jplayer",
supplied : "mp3, ogg, m4a",
wmode : "window",
loop : false,
preload : 'auto'
});
playFile = function(fileName, loadCompleteCallback) {
var $jplayer = $('#jplayer');
var hasCallbackFired = false;
var wrappedCallback = function(event) {
hasCallbackFired = true;
$jplayer.unbind($.jPlayer.event.loadeddata, wrappedCallback);
loadCompleteCallback($jplayer, event);
}
$jplayer.bind($.jPlayer.event.loadeddata, wrappedCallback);
setTimeout(function() {
if (!hasCallbackFired) {
wrappedCallback($jplayer);
}
}, 1500);
$jplayer.jPlayer('setMedia', {
mp3 : 'media/audio/' + fileName + '.mp3',
ogg : 'media/audio/' + fileName + '.ogg',
m4a : 'media/audio/' + fileName + '.m4a'
}).jPlayer('load');
}
</script>
<a href="javascript: playFile('0', function($jplayer, event) { $jplayer.jPlayer('play'); });">Play #0</a><br />
<a href="javascript: playFile('1', function($jplayer, event) { $jplayer.jPlayer('play'); });">Play #1</a><br />
<a href="javascript: playFile('2', function($jplayer, event) { $jplayer.jPlayer('play'); });">Play #2</a><br />
<a href="javascript: playFile('3', function($jplayer, event) { $jplayer.jPlayer('play'); });">Play #3</a><br />
<a href="javascript: playFile('4', function($jplayer, event) { $jplayer.jPlayer('play'); });">Play #4</a><br />
<a href="javascript: playFile('5', function($jplayer, event) { $jplayer.jPlayer('play'); });">Play #5</a><br />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment