/* Version: MPL 1.1 The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. The Original Code is mp3player (http://code.google.com/p/mp3player/). The Initial Developer of the Original Code is neolao (neolao@gmail.com). */ /** * Template for several mp3 * * @author neolao * @version 1.2.1 (04/01/2008) * @license http://creativecommons.org/licenses/by-sa/3.0/deed.fr */ class TemplateMulti extends ATemplate { // ------------------------------ VARIABLES -------------------------------- /** * Template width */ private var _width:Number = 200; /** * Template height */ private var _height:Number = 100; /** * Toolbar height */ private var _playerHeight:Number = 20; private var _backgroundSkin:String; private var _backgroundColor:Number; private var _backgroundColor1:Number = 0x7c7c7c; private var _backgroundColor2:Number = 0x000000; private var _buttonColor:Number = 0xffffff; private var _buttonOverColor:Number = 0xffff00; private var _sliderColor1:Number = 0xcccccc; private var _sliderColor2:Number = 0x888888; private var _sliderOverColor:Number = 0xeeee00; private var _textColor:Number = 0xffffff; private var _loadingColor:Number = 0xffff00; private var _playlistColor:Number = 0x000000; private var _playlistAlpha:Number = 50; private var _currentMp3Color:Number = 0xffff00; private var _scrollbarColor:Number = 0xffffff; private var _scrollbarOverColor:Number = 0xffff00; private var _showList:Boolean = true; private var _showSlider:Boolean = true; private var _title:Array; private var _showInfo:Boolean = false; private var _showVolume:Boolean = false; private var _volume:Number = 100; private var _volumeMax:Number = 200; private var _showLoading:String = "autohide"; // always, autohide, never private var _showPlaylistNumbers:Boolean = true; public var buttonWidth:Number = 26; public var volumeWidth:Number = 30; public var volumeHeight:Number = 6; public var sliderWidth:Number = 20; public var sliderHeight:Number = 10; private var _target:MovieClip = _root; private var _backgroundInstance:MovieClip; private var _previousButtonInstance:MovieClip; private var _playButtonInstance:MovieClip; private var _pauseButtonInstance:MovieClip; private var _stopButtonInstance:MovieClip; private var _infoButtonInstance:MovieClip; private var _infoPanel:MovieClip; private var _nextButtonInstance:MovieClip; private var _volumeButtonInstance:MovieClip; private var _separatorsInstance:MovieClip; private var _sliderInstance:MovieClip; private var _loadingInstance:MovieClip; private var _playlistInstance:MovieClip; private var _scrollbarInstance:MovieClip; private var _currentIndex:Number = 0; /*============================= CONSTRUCTEUR =============================*/ /*========================================================================*/ /** * Constructor */ public function TemplateMulti() { super(); // Initialisation du Stage Stage.scaleMode = "noScale"; Stage.align = "TL"; this._initVars(); if (!this._showList) { this._height = this._playerHeight; } this._initBackground(); this._initPreviousButton(); this._initPlayButton(); this._initPauseButton(); this._initStopButton(); this._initInfoButton(); this._initNextButton(); this._initVolumeButton(); var vMarginSlider:Number = this.buttonWidth*4; var vSeparators:Array = [this.buttonWidth, this.buttonWidth, this.buttonWidth, this.buttonWidth]; if (this._showInfo) { vMarginSlider += this.buttonWidth; vSeparators.push(this.buttonWidth); } if (this._showVolume) { vMarginSlider += this.volumeWidth; vSeparators.push(this.volumeWidth); } if (this._showSlider) { this._initSlider(vMarginSlider); } else { vMarginSlider -= this.buttonWidth; vSeparators.pop(); } this._createSeparators(vSeparators); // Si la playlist est générée avec un fichier // Alors il ne faut pas encore créer l'affichage de la playlist if (_root.playlist != undefined) { this._loadPlaylist(_root.playlist); } else { // Use postcast rss if (_root.playlistrss != undefined) { this._loadPlaylistRss(_root.playlistrss); } else { this._initPlaylist(); } } this._initInfoPanel(); // Raccourcis clavier var vPlayPause:Function = this.delegate(this, function() { if (this.player.isPlaying) { this.pauseRelease(); } else { this.playRelease(); } }); var vDecreaseVolume:Function = this.delegate(this, function() { var vVolume:Number = this._volume; vVolume -= 10; if (vVolume < 0) { vVolume = 0; } this.setVolume(vVolume); }); var vIncreaseVolume:Function = this.delegate(this, function() { var vVolume:Number = this._volume; vVolume += 10; if (vVolume > this._volumeMax) { vVolume = this._volumeMax; } this.setVolume(vVolume); }); // touche "Espace" this._addShortcut(32, vPlayPause); // touche "P" this._addShortcut(80, vPlayPause); // touche "S" this._addShortcut(83, this.delegate(this, function() { this.stopRelease(); })); // touche flèche gauche this._addShortcut(37, this.delegate(this, function() { this.player.setPosition(this.player.getPosition() - 5000); })); // touche flèche droite this._addShortcut(39, this.delegate(this, function() { this.player.setPosition(this.player.getPosition() + 5000); })); // touche flèche haut this._addShortcut(38, this.delegate(this, function() { if (this.player.hasPrevious) { this.previousRelease(); } })); // touche flèche bas this._addShortcut(40, this.delegate(this, function() { if (this.player.hasNext) { this.nextRelease(); } })); // touche "-" this._addShortcut(109, vDecreaseVolume); this._addShortcut(189, vDecreaseVolume); // touche "+" this._addShortcut(107, vIncreaseVolume); this._addShortcut(187, vIncreaseVolume); // touche "I" this._addShortcut(73, this.delegate(this, function() { this.infoRelease(); })); } /** * Launched by mtasc */ static function main():Void { // On vérifie s'il y a un fichier de configuration à charger if (_root.config != undefined) { // Fichier de configuration texte var vConfigLoad:LoadVars = new LoadVars(); vConfigLoad.onData = function(data:String) { if (data != undefined) { data = data.split("\r\n").join("\n"); var newdata:Array = data.split("\n"); for (var i=0; i