Всем привет.
Имеется следующий плеер
http://www.macloo.com/examples/audio_player/
Проблема в следующем.
Плеер проигрывает файлы только расположенные непосредственно на моем сайте, при ссылках на музыку с других сайтов отказывается воспроизводить.
Как можно исправить эту проблему.
Вот есть такой код, не знаю в нем ли кроется решение этой проблемы
PHP код:
//Frame 0
// Action tag #0
function millisecondsToString(position)
{
var __reg1 = new Date();
var __reg2 = undefined;
var __reg3 = undefined;
var hours;
__reg1.setSeconds(int(position / 1000));
__reg1.setMinutes(int(position / 1000 / 60));
__reg1.setHours(int(position / 1000 / 60 / 60));
__reg2 = __reg1.getSeconds();
__reg3 = __reg1.getMinutes();
hours = __reg1.getHours();
if (__reg2 < 10)
{
__reg2 = "0" + __reg2.toString();
}
if (__reg3 < 10)
{
__reg3 = "0" + __reg3.toString();
}
if (hours < 10)
{
hours = "0" + hours.toString();
}
return hours + ":" + __reg3 + ":" + __reg2;
}
src = soundFile == undefined ? "" : soundFile;
if (autostart == "yes")
{
autoOpen = true;
}
else
{
autoOpen = false;
}
autostart = undefined;
closePlayer = false;
setcolors = true;
emff = new Object();
emff.mySound = new Array();
emff.playedmsec = 0;
emff.index = 0;
emff.status = 0;
emff.dragpos = false;
emff.dragvol = false;
emff.STOPPED = 0;
emff.PLAYING = 1;
emff.PAUSED = 2;
emff.loop = false;
emff.autostart = false;
emff.streaming = true;
emff.src = src.split(",");
emff.isLoaded = new Array();
emff.getSoundNumber = function ()
{
return emff.src.length;
}
;
i = 0;
while (i < emff.getSoundNumber())
{
emff.isLoaded.push(false);
emff.mySound.push(new Sound());
++i;
}
emff.setVolume = function (vol)
{
if (vol < 0)
{
vol = 0;
}
if (vol > 100)
{
vol = 100;
}
i = 0;
for (;;)
{
if (i >= emff.getSoundNumber())
{
return;
}
emff.mySound[i].setVolume(vol);
++i;
}
}
;
emff.setVolume(100);
emff.loadSelectedSound = function ()
{
emff.mySound[emff.index].loadSound(emff.src[emff.index], emff.streaming);
emff.isLoaded[emff.index] = true;
}
;
emff.ctrlBegin = function ()
{
if (emff.status != emff.STOPPED)
{
emff.mySound[emff.index].stop();
}
emff.index = 0;
if (!emff.isLoaded[emff.index])
{
emff.loadSelectedSound();
}
emff.mySound[emff.index].start();
emff.status = emff.PLAYING;
}
;
emff.ctrlStop = function ()
{
if (emff.status != emff.STOPPED)
{
emff.mySound[emff.index].stop();
emff.status = emff.STOPPED;
}
}
;
emff.ctrlPause = function ()
{
if (emff.status == emff.PLAYING)
{
emff.playedmsec = emff.mySound[emff.index].position;
emff.mySound[emff.index].stop();
emff.status = emff.PAUSED;
}
}
;
emff.ctrlPlay = function ()
{
if (emff.status == emff.STOPPED)
{
if (!emff.isLoaded[emff.index])
{
emff.loadSelectedSound();
}
emff.mySound[emff.index].start();
emff.status = emff.PLAYING;
}
if (emff.status == emff.PAUSED)
{
emff.mySound[emff.index].start(Math.round(emff.playedmsec / 1000));
emff.status = emff.PLAYING;
}
}
;
emff.ctrlPrevious = function ()
{
emff.mySound[emff.index].stop();
if (emff.index <= 0)
{
emff.index = emff.getSoundNumber() - 1;
}
else
{
emff.index = emff.index - 1;
}
if (emff.status != emff.STOPPED)
{
if (!emff.isLoaded[emff.index])
{
emff.loadSelectedSound();
}
emff.mySound[emff.index].start();
emff.status = emff.PLAYING;
}
}
;
emff.ctrlNext = function ()
{
emff.mySound[emff.index].stop();
if (emff.index >= emff.getSoundNumber() - 1)
{
emff.index = 0;
}
else
{
emff.index = emff.index + 1;
}
if (emff.status != emff.STOPPED)
{
if (!emff.isLoaded[emff.index])
{
emff.loadSelectedSound();
}
emff.mySound[emff.index].start();
emff.status = emff.PLAYING;
}
}
;
i = 0;
while (i < emff.getSoundNumber())
{
emff.mySound[i].onSoundComplete = function ()
{
emff.mySound[emff.index].stop();
if (emff.index < emff.getSoundNumber() - 1)
{
emff.ctrlNext();
return;
}
if (emff.loop)
{
emff.ctrlNext();
return;
}
emff.index = 0;
emff.status = emff.STOPPED;
}
;
++i;
}
emff.getLoaded = function ()
{
if (!emff.isLoaded[emff.index])
{
return 0;
}
return emff.mySound[emff.index].getBytesLoaded() / emff.mySound[emff.index].getBytesTotal();
}
;
emff.getPlayed = function ()
{
if (emff.status == emff.STOPPED)
{
return 0;
}
if (emff.status == emff.PLAYING)
{
loaded = emff.mySound[emff.index].getBytesLoaded() / emff.mySound[emff.index].getBytesTotal();
playedmsec = emff.mySound[emff.index].position;
totalmsec = 1 / loaded * emff.mySound[emff.index].duration;
return playedmsec / totalmsec;
}
if (emff.status == emff.PAUSED)
{
loaded = emff.mySound[emff.index].getBytesLoaded() / emff.mySound[emff.index].getBytesTotal();
playedmsec = emff.playedmsec;
totalmsec = 1 / loaded * emff.mySound[emff.index].duration;
return playedmsec / totalmsec;
}
return 0;
}
;
if (autostart == "yes")
{
emff.autostart = true;
}
if (loop == "yes")
{
emff.loop = true;
}
if (streaming == "no")
{
emff.streaming = false;
}
_global.emff = emff;
emff.id3Tags = new Array(emff.getSoundNumber());
i = 0;
while (i < emff.getSoundNumber())
{
emff.mySound[i].error = false;
emff.mySound[i].index = i;
emff.id3Tags[i].loaded = false;
emff.mySound[i].onLoad = function (success)
{
this.error = !success;
}
;
emff.mySound[i].onID3 = function ()
{
emff.id3Tags[this.index] = new Object();
emff.id3Tags[this.index].data = new Array();
emff.id3Tags[this.index].data[0] = this.id3.artist;
emff.id3Tags[this.index].data[1] = this.id3.songname;
emff.id3Tags[this.index].loaded = true;
}
;
++i;
}
emff.getSongInfo = function ()
{
return emff.id3Tags[emff.index];
}
;
emff.getError = function ()
{
return emff.mySound[emff.index].error;
}
;
emff.getPosition = function ()
{
return emff.mySound[emff.index].position;
}
;
emff.getDuration = function ()
{
return emff.mySound[emff.index].duration;
}
;
_global.player = new Object();
player.maxVolume = 100;
player.volume = player.maxVolume;
player.fadeOut = false;
player.buffering = true;
player.setcolors = false;
player.CLOSED = 0;
player.OPENING = 1;
player.OPEN = 2;
player.CLOSING = 3;
player.status = player.CLOSED;
player.close = function ()
{
if (player.status == player.OPEN)
{
player.status = player.CLOSING;
player.fadeOut = true;
closePlayer = false;
_root.speaker_mc.gotoAndStop("off");
_root.play();
}
}
;
player.open = function ()
{
if (player.status == player.CLOSED)
{
player.status = player.OPENING;
_root.play();
if (playerID != undefined)
{
getURL("javascript:ap_stopAll(" + playerID + ")", "");
}
}
}
;
_root.control_mc.onRelease = function ()
{
if ((__reg0 = player.status) === player.CLOSED)
{
player.open();
return;
}
else
{
if (__reg0 !== player.OPEN)
{
return;
}
}
player.close();
return;
}
;
_root.control_mc.hover = false;
_root.control_mc.state = "play";
_root.control_mc.onRollOver = function ()
{
_root.control_mc.hover = true;
}
;
_root.control_mc.onRollOut = function ()
{
_root.control_mc.hover = false;
}
;
_root.control_mc.onEnterFrame = function ()
{
if (this.state == "play")
{
this.pause_icon_mc._visible = this.pause_hover_icon_mc._visible = false;
this.play_icon_mc._visible = !this.hover;
this.play_hover_icon_mc._visible = this.hover;
}
else
{
this.play_icon_mc._visible = this.play_hover_icon_mc._visible = false;
this.pause_icon_mc._visible = !this.hover;
this.pause_hover_icon_mc._visible = this.hover;
}
this.btn_hover_background_mc._visible = this.hover;
this.btn_background_mc._visible = !this.hover;
}
;
_root.progress_mc.progress_button_mc.onPress = function ()
{
emff.ctrlPause();
var __reg1 = Math.floor(186 * emff.getLoaded() - 3);
startDrag(this, 0, -3, -2, __reg1, -2);
emff.dragpos = true;
updateAfterEvent();
}
;
_root.progress_mc.progress_button_mc.onRelease = _root.progress_mc.progress_button_mc.onReleaseOutside = function ()
{
stopDrag();
var __reg1 = (this._x + 3) / 186;
var __reg2 = emff.getLoaded();
if (__reg1 > __reg2)
{
__reg1 = __reg2;
}
emff.playedmsec = Math.round(1 / __reg2 * emff.getDuration() * __reg1);
emff.ctrlPlay();
emff.dragpos = false;
}
;
_root.songInfo_mc.started = false;
_root.songInfo_mc.index = -1;
_root.songInfo_mc.pause = true;
_root.songInfo_mc.pauseLength = 60;
_root.songInfo_mc.scrollStep = 1;
_root.songInfo_mc.pauseCounter = 0;
_root.songInfo_mc.useHandCursor = false;
_root.songInfo_mc.onRelease = function ()
{
this.textMask_mc.gotoAndPlay("next");
}
;
_root.songInfo_mc.nextField = function (newIndex)
{
if (!this.started)
{
this.started = true;
}
if (newIndex == undefined)
{
if (this.index == emff.getSongInfo().data.length - 1)
{
this.index = 0;
}
else
{
++this.index;
}
}
else
{
this.index = newIndex;
}
this.input_txt.text = emff.getSongInfo().data[this.index];
this.input_txt.hscroll = 0;
this.pause = true;
this.forward = true;
this.pauseCounter = 0;
this.textMask_mc.gotoAndPlay("start");
}
;
_root.songInfo_mc.onEnterFrame = function ()
{
this.input_txt.background = false;
if (this.input_txt.length == 0 || this.input_txt.maxhscroll == 0)
{
return;
}
if (this.pause)
{
if (this.pauseCounter == this.pauseLength)
{
this.pause = false;
this.pauseCounter = 0;
}
else
{
++this.pauseCounter;
return;
}
}
if (this.forward)
{
this.input_txt.hscroll = this.input_txt.hscroll + this.scrollStep;
if (this.input_txt.hscroll >= this.input_txt.maxhscroll)
{
this.forward = false;
this.pause = true;
return;
}
return;
}
this.input_txt.hscroll = this.input_txt.hscroll - this.scrollStep;
if (this.input_txt.hscroll == 0)
{
this.pause = true;
this.forward = true;
return;
}
}
;
lastPosition = 0;
frameCount = 0;
trackIndex = 0;
_root.onEnterFrame = function ()
{
if (setcolors)
{
player.setColors();
setcolors = false;
}
if (closePlayer)
{
player.close();
}
if (emff.getSoundNumber() == 0)
{
player.error = true;
}
else
{
player.error = emff.getError();
}
if (player.error)
{
_root.progress_mc.progress_button_mc._visible = false;
_root.speaker_mc.gotoAndStop("off");
_root.messages_txt.text = "Error opening file";
_root.messages_txt._visible = player.status == player.OPEN;
_root.position_txt._visible = false;
_root.songInfo_mc._visible = false;
return undefined;
}
_root.position_txt._visible = true;
if (player.fadeOut)
{
player.volume = player.volume - 8;
if (player.volume < 10)
{
emff.ctrlPause();
player.fadeOut = false;
}
}
else
{
if (player.status == player.OPEN)
{
player.volume = player.maxVolume;
}
}
emff.setVolume(player.volume);
_root.progress_mc.loading_mc._width = Math.round(emff.getLoaded() * 200);
if (player.buffering)
{
_root.messages_txt.text = "Buffering...";
_root.messages_txt._visible = true;
_root.songInfo_mc._visible = false;
}
else
{
_root.messages_txt._visible = false;
with (_root.songInfo_mc)
{
if (_global.emff.getSongInfo().loaded)
{
if (_root.trackIndex == emff.index)
{
if (!started)
{
nextField();
}
}
else
{
_root.trackIndex = emff.index;
nextField(0);
}
_visible = true;
}
else
{
_visible = false;
}
}
}
if ((__reg0 = emff.status) === emff.PLAYING)
{
++frameCount;
if (frameCount == 5)
{
frameCount = 0;
player.buffering = emff.getPosition() == lastPosition;
lastPosition = emff.getPosition();
}
_root.progress_mc.progress_button_mc._visible = true;
if (!emff.dragpos)
{
_root.progress_mc.progress_button_mc._x = Math.round(emff.getPlayed() * 186 - 3);
}
_root.position_txt.text = millisecondsToString(emff.getPosition());
_root.control_mc.state = "pause";
}
else
{
if (__reg0 === emff.PAUSED)
{
_root.position_txt.text = millisecondsToString(emff.getPosition());
if (!emff.dragpos)
{
_root.control_mc.state = "play";
}
}
else
{
if (__reg0 === emff.STOPPED)
{
lastPosition = 0;
_root.progress_mc.progress_button_mc._visible = false;
_root.position_txt.text = millisecondsToString(0);
_root.progress_mc.progress_button_mc._x = -3;
_root.control_mc.state = "play";
player.close();
}
}
}
if (player.status != player.OPEN)
{
_root.messages_txt._visible = false;
_root.songInfo_mc._visible = false;
_root.position_txt._visible = false;
}
}
;
player.setColors = function ()
{
var __reg2 = undefined;
var __reg1 = new Object();
__reg1.bg = bg;
__reg1.leftbg = leftbg;
__reg1.lefticon = lefticon;
__reg1.rightbg = rightbg;
__reg1.rightbghover = rightbghover;
__reg1.righticon = righticon;
__reg1.righticonhover = righticonhover;
__reg1.text = text;
__reg1.slider = slider;
__reg1.track = track;
__reg1.loader = loader;
__reg1.border = border;
if (__reg1.bg != undefined)
{
__reg2 = new Color(background_mc);
__reg2.setRGB(__reg1.bg);
__reg2 = new Color(songInfo_mc.textmask_mc);
__reg2.setRGB(__reg1.bg);
}
if (__reg1.leftbg != undefined)
{
__reg2 = new Color(left_background_mc);
__reg2.setRGB(__reg1.leftbg);
}
if (__reg1.lefticon != undefined)
{
__reg2 = new Color(speaker_mc);
__reg2.setRGB(__reg1.lefticon);
}
if (__reg1.rightbg != undefined)
{
__reg2 = new Color(control_mc.btn_background_mc);
__reg2.setRGB(__reg1.rightbg);
}
if (__reg1.rightbghover != undefined)
{
__reg2 = new Color(control_mc.btn_hover_background_mc);
__reg2.setRGB(__reg1.rightbghover);
}
if (__reg1.righticon != undefined)
{
__reg2 = new Color(control_mc.play_icon_mc);
__reg2.setRGB(__reg1.righticon);
__reg2 = new Color(control_mc.pause_icon_mc);
__reg2.setRGB(__reg1.righticon);
}
if (__reg1.righticonhover != undefined)
{
__reg2 = new Color(control_mc.play_hover_icon_mc);
__reg2.setRGB(__reg1.righticonhover);
__reg2 = new Color(control_mc.pause_hover_icon_mc);
__reg2.setRGB(__reg1.righticonhover);
}
if (__reg1.text != undefined)
{
messages_txt.textColor = position_txt.textColor = songInfo_mc.input_txt.textColor = __reg1.text;
}
if (__reg1.slider != undefined)
{
__reg2 = new Color(progress_mc.progress_button_mc);
__reg2.setRGB(__reg1.slider);
}
if (__reg1.track != undefined)
{
__reg2 = new Color(progress_mc.track_mc);
__reg2.setRGB(__reg1.track);
}
if (__reg1.loader != undefined)
{
__reg2 = new Color(progress_mc.loader_mc);
__reg2.setRGB(__reg1.loader);
}
if (__reg1.border != undefined)
{
__reg2 = new Color(progress_mc.border_mc);
__reg2.setRGB(__reg1.border);
}
}
;
//Frame 1
// Action tag #0
player.status = player.CLOSED;
if (autoOpen)
{
play();
}
else
{
stop();
}
//Frame 2
// Action tag #0
autoOpen = false;
//Frame 15
// Action tag #0
player.status = player.OPEN;
emff.ctrlPlay();
_root.speaker_mc.gotoAndPlay("on");
stop();
//Frame 25
// Action tag #0
gotoAndStop("closed");
//Sprite 17
// Frame 0
// Action tag #0
stop();
// Frame 269
// Action tag #0
stop();
_parent.nextField();
//Sprite 25
// Frame 0
// Action tag #0
stop();
// Frame 21
// Action tag #0
gotoAndPlay("on");