Файл: user/files/audio-player-noswfobject.js
Строк: 166
<?php
var AudioPlayer = function () {
var instances = [];
var groups = {};
var activePlayers = {};
var playerURL = "";
var defaultOptions = {};
var currentVolume = -1;
var requiredFlashVersion = "9";
function getPlayer(playerID) {
if (document.all && !window[playerID]) {
for (var i = 0; i < document.forms.length; i++) {
if (document.forms[i][playerID]) {
return document.forms[i][playerID];
break;
}
}
}
return document.all ? window[playerID] : document[playerID];
}
function addListener (playerID, type, func) {
getPlayer(playerID).addListener(type, func);
}
return {
setup: function (url, options) {
playerURL = url;
defaultOptions = options;
if (swfobject.hasFlashPlayerVersion(requiredFlashVersion)) {
swfobject.switchOffAutoHideShow();
swfobject.createCSS("p.audioplayer_container span", "visibility:hidden;height:24px;overflow:hidden;padding:0;border:none;");
}
},
getPlayer: function (playerID) {
return getPlayer(playerID);
},
addListener: function (playerID, type, func) {
addListener(playerID, type, func);
},
embed: function (elementID, options) {
var instanceOptions = {};
var key;
var flashParams = {};
var flashVars = {};
var flashAttributes = {};
// Merge default options and instance options
for (key in defaultOptions) {
instanceOptions[key] = defaultOptions[key];
}
for (key in options) {
instanceOptions[key] = options[key];
}
if (instanceOptions.transparentpagebg == "yes") {
flashParams.bgcolor = "#FFFFFF";
flashParams.wmode = "transparent";
} else {
if (instanceOptions.pagebg) {
flashParams.bgcolor = "#" + instanceOptions.pagebg;
}
flashParams.wmode = "opaque";
}
flashParams.menu = "false";
for (key in instanceOptions) {
if (key == "pagebg" || key == "width" || key == "transparentpagebg") {
continue;
}
flashVars[key] = instanceOptions[key];
}
flashAttributes.name = elementID;
flashAttributes.style = "outline: none";
flashVars.playerID = elementID;
swfobject.embedSWF(playerURL, elementID, instanceOptions.width.toString(), "24", requiredFlashVersion, false, flashVars, flashParams, flashAttributes);
instances.push(elementID);
if (options.group) {
groups[elementID] = options.group;
}
},
syncVolumes: function (playerID, volume) {
if (groups[playerID]) return;
currentVolume = volume;
for (var i = 0; i < instances.length; i++) {
if (!groups[instances[i]] && instances[i] != playerID) {
getPlayer(instances[i]).setVolume(currentVolume);
}
}
},
activate: function (playerID, info) {
for (var activePlayerID in activePlayers) {
if (activePlayerID == playerID) {
continue;
}
if (groups[playerID] != groups[activePlayerID]) {
this.close(activePlayerID);
continue;
}
if (!(groups[playerID] || groups[activePlayerID])) {
this.close(activePlayerID);
}
}
activePlayers[playerID] = 1;
},
load: function (playerID, soundFile, titles, artists) {
getPlayer(playerID).load(soundFile, titles, artists);
},
close: function (playerID) {
getPlayer(playerID).close();
if (playerID in activePlayers) {
delete activePlayers[playerID];
}
},
open: function (playerID, index) {
if (index == undefined) {
index = 1;
}
getPlayer(playerID).open(index == undefined ? 0 : index-1);
},
getVolume: function (playerID) {
return currentVolume;
}
}
}();
?>