function modifyStage()
{
function goTo()
{
getURL("http://components.developers4web.com/mini-mp3-flash-player", "_blank");
}
var __reg2 = new ContextMenu();
__reg2.hideBuiltInItems();
__reg2.customItems.push(new ContextMenuItem("MiniPlayer Flash MP3 Player", goTo));
_root.menu = __reg2;
Stage.scaleMode = "noScale";
Stage.align = "TL";
}
function configure(configurationFile)
{
var __reg5 = new XML();
__reg5.ignoreWhite = true;
__reg5.onLoad = function (success)
{
if (success)
{
var __reg3 = undefined;
var __reg4 = 0;
while (__reg4 < this.firstChild.childNodes.length)
{
__reg3 = this.firstChild.childNodes[__reg4];
if (__reg3.nodeType == 1)
{
if ((__reg0 = __reg3.nodeName.toLowerCase()) === "skinoptions")
{
_root.readSkinoptions(__reg3);
}
else
{
if (__reg0 === "functionality")
{
_root.readFunctionality(__reg3);
}
}
}
++__reg4;
}
_root.player = new TSPlayer(_level0.playlistfile);
return;
}
mx.controls.Alert.show("Please check the XML configuration file structure", "Error");
}
;
__reg5.load(configurationFile);
}
function readFunctionality(node)
{
var __reg2 = 0;
for (;;)
{
if (__reg2 >= node.childNodes.length)
{
return;
}
if (node.childNodes[__reg2].nodeType == 1)
{
if ((__reg0 = node.childNodes[__reg2].nodeName.toLowerCase()) === "autoplay")
{
if (node.childNodes[__reg2].firstChild.nodeValue == 0)
{
_root.confAutoplay = false;
}
}
else
{
if (__reg0 === "volume")
{
if (!isNaN(Number(node.childNodes[__reg2].firstChild.nodeValue)))
{
_root.volumeValue = Number(node.childNodes[__reg2].firstChild.nodeValue);
}
}
else
{
if (__reg0 === "repeat")
{
if (node.childNodes[__reg2].firstChild.nodeValue == 0)
{
_root.confRepeat = false;
}
}
else
{
if (__reg0 === "shuffling")
{
if (node.childNodes[__reg2].firstChild.nodeValue == 1)
{
_root.confShuffling = true;
}
}
}
}
}
}
++__reg2;
}
}
function titleTextFieldFormat()
{
_root.skinContainer.dataTxt.background = false;
_root.skinContainer.dataTxt.border = false;
}
function scrollDataTxt()
{
if (_root.skinContainer.dataTxt.hscroll == 0)
{
_root.displacementhscroll = 1;
}
else
{
if (_root.skinContainer.dataTxt.hscroll == _root.skinContainer.dataTxt.maxhscroll)
{
_root.displacementhscroll = -1;
}
}
_root.skinContainer.dataTxt.hscroll = _root.skinContainer.dataTxt.hscroll + _root.displacementhscroll;
titleTextFieldFormat();
}
function showMusicData()
{
var __reg3 = _root.player.getData();
__reg3 = __reg3.toUpperCase();
_root.writeInformationalPanel(__reg3);
if (_root.skinContainer.dataTxt.maxhscroll > 0)
{
if (_root.scrollIntervalId != undefined)
{
clearInterval(_root.scrollIntervalId);
}
_root.scrollIntervalId = setInterval(this, "scrollDataTxt", 100);
}
}
function writeInformationalPanel(information)
{
_root.skinContainer.dataTxt.text = information;
titleTextFieldFormat();
}
function btnDeactivateState()
{
_root.skinContainer.playBtn.gotoAndStop("inactive");
_root.skinContainer.pauseBtn.gotoAndStop("inactive");
_root.skinContainer.stopBtn.gotoAndStop("inactive");
}
function clearTimerDisplay()
{
_root.skinContainer.numTimer.timerText.text = "00:00";
_root.skinContainer.numTimer.timerShadow.text = _root.skinContainer.numTimer.timerText.text;
}
function volumeEnter()
{
_root.skinContainer.volumeControl.volumeControl_mask._x = _root.volumeValue * _root.skinContainer.volumeControl.volumeControlPath._width / 100 + _root.skinContainer.volumeControl.volumeControlPath._x - _root.skinContainer.volumeControl.volumeControl_mask._width;
}
function setDisplacement(duration)
{
_root.displacement = (_root.skinContainer.displacementPath._width - _root.skinContainer.displacementBtn._width) / duration;
}
function resetDisplacement()
{
_root.skinContainer.displacementBtn._x = _root.skinContainer.displacementPath._x;
_root.skinContainer.position_mask._x = _root.skinContainer.displacementBtn._x - _root.skinContainer.position_mask._width;
}
function rollOverAction(element)
{
_root.rolloverFlag = true;
element = element.toUpperCase();
_root.writeInformationalPanel(element);
}
function rollOutAction(element)
{
_root.rolloverFlag = false;
_root.writeInformationalPanel(" ");
if (_root.playerState != 0)
{
_root.showMusicData();
}
}
function setState(stateValue)
{
_root.playerState = stateValue;
}
function fnt_displacementBtn_press()
{
if (_root.playerState != 0)
{
clearInterval(_root.displacementInterval);
startDrag(_root.skinContainer.displacementBtn, 0, _root.skinContainer.displacementPath._x, _root.skinContainer.displacementBtn._y, _root.skinContainer.displacementPath._x + _root.skinContainer.displacementPath._width - _root.skinContainer.displacementBtn._width, _root.skinContainer.displacementBtn._y);
Mouse.addListener(mouseListener);
}
}
function fnt_displacementBtn_release()
{
if (_root.playerState != 0)
{
stopDrag();
if (_root.displacementInterval != undefined)
{
clearInterval(_root.displacementInterval);
}
_root.displacementInterval = setInterval(this, "displacementInTime", 1000);
Mouse.removeListener(mouseListener);
_root.player.setPosition(_root.positionValue);
_root.player.playMusic(_root.index);
}
}
function fnt_displacementPath_press()
{
if (_root.playerState != 0)
{
clearInterval(_root.displacementInterval);
if (_xmouse < _root.skinContainer.displacementBtn._x)
{
_root.skinContainer.displacementBtn._x = _xmouse;
}
else
{
_root.skinContainer.displacementBtn._x = _xmouse - _root.skinContainer.displacementBtn._width;
}
_root.skinContainer.position_mask._x = _root.skinContainer.displacementBtn._x - _root.skinContainer.position_mask._width;
_root.positionValue = (_root.skinContainer.displacementBtn._x - _root.skinContainer.displacementPath._x) * _root.player.getRealDuration() / (_root.skinContainer.displacementPath._width - _root.skinContainer.displacementBtn._width) * 1000;
_root.writeInformationalPanel("SEEK TO: " + Utils.transformTime(_root.positionValue.toString()));
_root.player.setPosition(_root.positionValue);
}
}
function fnt_displacementPath_release()
{
if (_root.playerState != 0)
{
_root.player.playMusic(_root.index);
}
}
function fnt_playBtn_state1()
{
if (_root.playerState != 0)
{
_root.player.playMusic(_root.index);
return;
}
if (_root.confAutoplay)
{
return;
}
_root.player.playMusic(_root.index);
_root.confAutoplay = true;
}
function fnt_playBtn_state2()
{
if (_root.playerState != 0)
{
_root.player.stopMusic();
_root.player.playMusic(_root.index);
}
}
function fnt_pauseBtn_state1()
{
if (_root.skinContainer.playBtn._currentframe == 2 && _root.playerState != 0)
{
_root.player.pauseMusic();
}
}
function fnt_pauseBtn_state2()
{
_root.player.playMusic(_root.index);
}
function fnt_stopBtn_state1()
{
if (_root.playerState != 0)
{
_root.player.stopMusic();
}
}
function fnt_nextBtn()
{
_root.player.nextMusic();
}
function fnt_previousBtn()
{
_root.player.previousMusic();
}
function fnt_cycleBtn_state1()
{
_root.player.setLoop(true);
_root.skinContainer.repeatBtn.gotoAndStop("active");
}
function fnt_cycleBtn_state2()
{
_root.player.setLoop(false);
_root.skinContainer.repeatBtn.gotoAndStop("inactive");
}
function fnt_randomBtn_state1()
{
_root.player.setRandom(true);
_root.skinContainer.shufflingBtn.gotoAndStop("active");
}
function fnt_randomBtn_state2()
{
_root.player.setRandom(false);
_root.skinContainer.shufflingBtn.gotoAndStop("inactive");
}
function fnt_volumeControl(volumeIn)
{
var __reg3 = undefined;
if (volumeIn == undefined)
{
__reg3 = this._xmouse;
_root.skinContainer.volumeControl.volumeControl_mask._x = __reg3 - _root.skinContainer.volumeControl._x - _root.skinContainer.volumeControl.volumeControl_mask._width;
_root.volumeValue = (__reg3 - _root.skinContainer.volumeControl._x) * 100 / _root.skinContainer.volumeControl.volumeControlPath._width;
}
else
{
_root.skinContainer.volumeControl.volumeControl_mask._x = _root.skinContainer.volumeControl.volumeControlPath._width * volumeIn / 100 - _root.skinContainer.volumeControl.volumeControl_mask._width;
}
_root.player.setVolume(_root.volumeValue);
if (_root.playerState == 3)
{
_root.equalizerDisplay(_root.volumeValue);
}
}
function timerDisplay()
{
_root.skinContainer.numTimer.timerText.text = _root.player.getPosition();
_root.skinContainer.numTimer.timerShadow.text = _root.skinContainer.numTimer.timerText.text;
}
function displacementInTime()
{
_root.skinContainer.displacementBtn._x = _root.skinContainer.displacementBtn._x + _root.displacement;
_root.skinContainer.position_mask._x = _root.skinContainer.displacementBtn._x - _root.skinContainer.position_mask._width;
}
function equalizerDisplay(index)
{
var __reg2 = undefined;
__reg2 = Math.ceil(index * _root.skinContainer.equalizer._totalframes / 100);
if (__reg2 < _root.skinContainer.equalizer._totalframes)
{
++__reg2;
}
_root.skinContainer.equalizer.gotoAndStop(__reg2);
}
function playerReady()
{
_root.fnt_volumeControl(_root.volumeValue);
if (_root.confRepeat == true)
{
_root.player.setLoop(_root.confRepeat);
_root.skinContainer.repeatBtn.gotoAndStop("active");
}
else
{
_root.player.setLoop(_root.confRepeat);
_root.skinContainer.repeatBtn.gotoAndStop("inactive");
}
if (_root.confShuffling == true)
{
_root.player.setRandom(_root.confShuffling);
_root.skinContainer.shufflingBtn.gotoAndStop("active");
}
else
{
_root.player.setRandom(_root.confShuffling);
_root.skinContainer.shufflingBtn.gotoAndStop("inactive");
}
if (_root.confAutoplay == true)
{
_root.player.playMusic(0);
}
_root.skinContainer.enabled = true;
}
function musicInitialization(activeMusicIndex, position)
{
_root.setDisplacement(_root.player.getRealDuration());
_root.index = activeMusicIndex;
_root.setState(3);
if (_root.intervalId != undefined)
{
clearInterval(_root.intervalId);
}
_root.intervalId = setInterval(this, "timerDisplay", 1000);
if (_root.displacementInterval != undefined)
{
clearInterval(_root.displacementInterval);
}
_root.displacementInterval = setInterval(this, "displacementInTime", 1000);
_root.showMusicData();
btnDeactivateState();
_root.skinContainer.playBtn.gotoAndStop("active");
_root.equalizerDisplay(_root.player.getVolume());
}
function musicPause(activeMusicIndex, position)
{
_root.index = activeMusicIndex;
_root.setState(2);
clearInterval(_root.intervalId);
clearInterval(_root.displacementInterval);
btnDeactivateState();
_root.skinContainer.pauseBtn.gotoAndStop("active");
_root.equalizerDisplay(0);
}
function musicStop(activeMusicIndex)
{
_root.index = activeMusicIndex;
_root.setState(1);
clearInterval(_root.intervalId);
clearInterval(_root.displacementInterval);
_root.resetDisplacement();
btnDeactivateState();
_root.skinContainer.stopBtn.gotoAndStop("active");
_root.clearTimerDisplay();
_root.equalizerDisplay(0);
}
mx.controls.Alert.setSize(250);
_level0.playlistfile = "demoplaylist/demoplaylist.xml";
_level0.configurationfile = "demoplaylist/democonfiguration.xml";
if (_level0.playlistfile == undefined)
{
mx.controls.Alert.show("Please the XML playlist file is required for music player application", "Error");
}
else
{
if (_level0.configurationfile == undefined)
{
mx.controls.Alert.show("Please the XML configuration file is required", "Error");
}
else
{
_root.configure(_level0.configurationfile);
}
}
var confAutoplay = true;
var confRepeat = true;
var confShuffling = false;
var player;
var index = 0;
var intervalId;
var displacementInterval;
var scrollIntervalId;
var volumeValue = 100;
var volumeBk;
var displacement;
var displacementhscroll = 1;
var positionValue;
var playerState = 0;
var rolloverFlag = false;
var mouseListener = new Object();
_root.listContainer._visible = false;
modifyStage();
mouseListener.onMouseMove = function ()
{
var __reg3 = undefined;
var __reg2 = _root.skinContainer.displacementBtn._width / 2;
__reg3 = _xmouse;
if (_xmouse >= _root.skinContainer.displacementPath._x + __reg2 && _xmouse <= _root.skinContainer.displacementPath._width + _root.skinContainer.displacementPath._x - __reg2)
{
_root.skinContainer.displacementBtn._x = __reg3 - __reg2;
_root.skinContainer.position_mask._x = _root.skinContainer.displacementBtn._x - _root.skinContainer.position_mask._width;
_root.positionValue = (_root.skinContainer.displacementBtn._x - _root.skinContainer.displacementPath._x) * _root.player.getRealDuration() / (_root.skinContainer.displacementPath._width - _root.skinContainer.displacementBtn._width) * 1000;
_root.writeInformationalPanel("SEEK TO: " + Utils.transformTime(_root.positionValue.toString()));
}
}
;