var currentSpecies = null; var controlsId = "#avb_controls"; var playerLoaded = false; function updateSound(json, metadata, playerId) { if (!json || !json.mp3 || !json.fileid) { if ($(metadata)) $(metadata).html("No Xeno-Canto recordings are available for this species."); return; } if ($(metadata)) $(metadata).html(" " + json.recordist + ". Accessible at : " + json.link + ""); if (!playerLoaded) { $(playerId).jPlayer({ ready: function() { jQuery(this).jPlayer("setMedia", { //mp3: json.mp3 mp3: "https://avibase.bsc-eoc.org/data/mp3proxy/" + json.fileid + ".mp3?fileid=" + json.fileid }).jPlayer("play"); }, //play: function() { // only play one audio clip at a time // jQuery(this).jPlayer("pauseOthers"); //}, timeupdate: function (e){ var Position = jQuery('.sono').position(); }, cssSelectorAncestor: "#birdsound_outer", swfPath: "/mobile/jquery.jplayer.swf", solution: "html,flash", supplied: "mp3", preload: "auto", errorAlerts: false, wmode: "window" }); playerLoaded = true; } else $(playerId).jPlayer("setMedia", { //mp3: json.mp3 mp3: "https://avibase.bsc-eoc.org/data/mp3proxy/" + json.fileid + ".mp3?fileid=" + json.fileid }).jPlayer("play"); } function changeSpeciesSnd(code, metadata, playerId) { currentSpecies = code; var json = (function () { var json = null; $.ajax({ 'async': true, 'global': false, 'url': 'sound_item.jsp', 'dataType': "json", 'data': {"avibaseid": code}, 'success': function (data) { json = data; updateSound(json, metadata, playerId); }, 'error': function (data) { updateSound(json, metadata, playerId); } }); return json; })(); } function stopRecording(playerId) { $(playerId).jPlayer("stop"); }