/*playerVersion = v3.6; Copyright (c) 2005, Fabricio Zuardi All rights reserved. Revisions by Lacy Morrow Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. [Updated 02/09/2007] by Esteban Sagrero @ www.e162s.com ** Fixed problem with player not stopping at last track. ** Disabled Video Playback. Can be reinstated. ** Added 2 Filters plus Color Option ** Added AutoScroll to Playlist area. ** Fixed the Resize bug. Could be customized more. ** Added Download Option via "on" and "off" [Updated 02/23/2007] ** Fixed alignment of bottom controls - was off by 20 pixels ** Added ability to download or NOT download album covers according to the player's mode (Slim Mode, Tall Mode, etc. . .) to save bandwidth that can be better used towards loading audiotracks. ** Added ability to turn on or off the "Time Counter" area. [Updated 12/07/2007] ** Fixed alignment of text on bottom control area - was not centered correctly. ** Added ability to turn off album area in the URL commands, but this option is only needed for when the player is set at 400 width and 170, yet the user wishes not to use the ablum area anyways. Option does not affect automatic album area removal when the player is set smaller than 334 in width via HTML, less than 170 in height via HTML, and larger than 389 in hieght via HTML. ** Fixed a few issues with shuffle and repeat button graphics. Altered both a bit, and added "ON" text to both. ** Fixed the overlay option, colors weren't showing up right. ** Adjusted the volume system to lessen distortion in Mp3s. Instead of 1 to 100 grading system, it will now be 1 to 50. ** Added ability to change the player's colors; this incudes buttons, background, and text. User might get unfavorable results using these color options with blend. Combine at your own artistic risk. :P [Updated 12/22/2007] ** Fixed alpha parameter interaction with bg_color parameter, also blend parameter. [Updated 01/01/2008] ** Corrected problem with Artist Info button. ** Player can now be used in another flash document via movie container while being able to adjust player height and width. See Appendix Page for details. A big thanks to howard.s for pointing out the kinks. ** Tweaked time display to now show up after playlist is fully loaded. [Updated 01/17/2008] ** Corrected a problem with display_time code. Fixed a few bugs in width and height code for use with Flash within Flash mode. */ stop(); DEFAULT_PLAYLIST_URL = "http://www.e162s.com/music_page/rock_list.xspf"; DEFAULT_WELCOME_MSG = "XSPF Mp3 Player v3.6 Updated 01.17.08"; LOADING_PLAYLIST_MSG = "Loading music ... "; DEFAULT_LOADED_PLAYLIST_MSG = "Playlist Loaded - Click Play"; DEFAULT_INFO_URL = "http://www.e162s.com/programs/xspf_player.htm"; //Playlists have priority over songs, if a playlist_url parameter is found the song_url is ignored //Default playlist if none is passed through query string if (!playlist_url) { if (!song_url) { playlist_url = DEFAULT_PLAYLIST_URL; } else { single_music_playlist = ""; single_music_playlist += ""+song_url+""+song_title+""; single_music_playlist += ""; } } //Options that can be actived via url string on Internet Browser if (!mainurl) { mainurl = DEFAULT_MAIN_URL; } if (repeat == 1 || repeat == true) { repeat = 1; information_mc.settings_mc.repeat_btn.gotoAndStop(1); } else { repeat = 0; information_mc.settings_mc.repeat_btn.gotoAndStop(2); } if (shuffle == 1 || shuffle == true) { shuffle = 1; information_mc.settings_mc.shuffle_btn.gotoAndStop(1); } else { shuffle = 0; information_mc.settings_mc.shuffle_btn.gotoAndStop(2); } if (!start_track) { start_track = 1; } if (!volume_level) { volume_level = 50; } if (!buffer) { buffer = 0; } if (!album == 0) { album = 0; } //Variables Initialization playlist_array = []; track_index = start_track-1; playlist_mc.track_count = 0; pause_position = 0; mouseListener = new Object(); top_section_mc.time_mc._visible = false; playlist_mc.tracks_mc._visible = false; playlist_xml = new XML(); playlist_xml.ignoreWhite = true; playlist_xml.onLoad = playlistLoaded; mysound = new Sound(); xmlData = new XML(); xmlData.ignoreWhite = true; xmlData.onLoad = loadimage; playlist_listener = new Object(); playlist_list.addEventListener("change", playlist_listener); //Playlist Function - Reads and Loads Playlist **DO NOT EDIT** function playlistLoaded(success) { if (success) { type = ""; var root_node = this.firstChild; for (var node = root_node.firstChild; node != null; node=node.nextSibling) { if (node.nodeName == "trackList") { //tracks var tracks_array = []; for (var track_node = node.firstChild; track_node != null; track_node=track_node.nextSibling) { var track_obj = new Object(); //track attributes for (var track_child = track_node.firstChild; track_child != null; track_child=track_child.nextSibling) { if (track_child.nodeName == "location") { track_obj.location = track_child.firstChild.nodeValue; } if (track_child.nodeName == "image" and !main_image) { track_obj.image = track_child.firstChild.nodeValue; } else if (main_image) { track_obj.image = main_image; } if (track_child.nodeName == "creator") { track_obj.creator = track_child.firstChild.nodeValue; } if (track_child.nodeName == "title") { track_obj.title = track_child.firstChild.nodeValue; } if (track_child.nodeName == "annotation") { track_obj.annotation = track_child.firstChild.nodeValue; } if (track_child.nodeName == "type") { track_obj.type = track_child.firstChild.nodeValue; } if (track_child.nodeName == "info") { track_obj.info = track_child.firstChild.nodeValue; } } track_obj.label = ""; if (track_obj.title) { if (track_obj.creator) { track_obj.label += track_obj.creator+' - '; } track_obj.label += track_obj.title; } else { track_obj.label += track_obj.annotation; } tracks_array.push(track_obj); } } } if (alphabetize == 1 || alphabetize == true) { tracks_array.sortOn(["label"], 17); } for (i=0; i4) && (image_load_percent == 100)) { //Image load //Make image fit album cover area cover_mc.photo_load_mc.imageloadMC._visible = false; cover_mc.content_mc["photo"]._width = cover_mc.load_bar_mc._width; cover_mc.content_mc["photo"]._height = cover_mc.load_bar_mc._height; } }; } // LOADS ALBUM COVER ART IF AUTOLOAD OPTION IS TURNED ON VIA URL COMMAND function preloadalbum() { playlist_mc.tracks_mc._visible = true; cover_mc.photo_load_mc._visible = true; cover_mc.content_mc["photo"].removeMovieClip(); cover_mc.photo_load_mc.imageloadMC.text = "LOADING ALBUM COVER"; cover_mc.photo_load_mc.imageloadMC._visible = true; if (playlist_array[track_index].image != undefined) { cover_mc.content_mc.createEmptyMovieClip("photo", track_index); cover_mc.content_mc["photo"].loadMovie(playlist_array[track_index].image); } else if (album_xml_jpg_data == false) { } else if (album_xml_jpg_data == 2) { xmlData.load("http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&Operation=ItemSearch&AWSAccessKeyId=0FHVSFEH0JNK8XSM7382&SearchIndex=Music&Artist="+playlist_array[track_index].creator+"&ResponseGroup=Images"); } _root.onEnterFrame = function() { var image_load_percent = (cover_mc.content_mc["photo"].getBytesLoaded()/cover_mc.content_mc["photo"].getBytesTotal())*100; cover_mc.load_bar_mc._xscale = image_load_percent; if ((cover_mc.content_mc["photo"].getBytesLoaded()>4) && (image_load_percent == 100)) { cover_mc.photo_load_mc.imageloadMC._visible = false; cover_mc.content_mc["photo"]._width = cover_mc.load_bar_mc._width; cover_mc.content_mc["photo"]._height = cover_mc.load_bar_mc._height; } }; } information_mc.info_text_mc.player_info_text.text = "PLAYER INFO"; information_mc.information_btn.onRollOver = function() { holderText = top_section_mc.track_display_mc.track_text_mc.display_txt.text; top_section_mc.track_display_mc.track_text_mc.display_txt.text = "Download @ www.e162s.com/xspf "; }; information_mc.information_btn.onPress = function() { getURL(DEFAULT_INFO_URL, "_blank"); }; //LOWER BUTTONS information_mc.settings_mc.shuffle_btn.onRollOver = function() { holderText = top_section_mc.track_display_mc.track_text_mc.display_txt.text; top_section_mc.track_display_mc.track_text_mc.display_txt.text = "SHUFFLE"; }; information_mc.settings_mc.repeat_btn.onRollOver = function() { holderText = top_section_mc.track_display_mc.track_text_mc.display_txt.text; top_section_mc.track_display_mc.track_text_mc.display_txt.text = "REPEAT TRACK"; }; information_mc.settings_mc.repeat_btn.onRollOut = information_mc.settings_mc.shuffle_btn.onRollOut=information_mc.information_btn.onRollOut=function () { top_section_mc.track_display_mc.track_text_mc.display_txt.text = holderText; }; //PLAY/STOP .ETC BUTTONS top_section_mc.buttons_mc.stop_btn.onRelease = stopTrack; top_section_mc.play_mc.play_btn.onRelease = playTrack; top_section_mc.buttons_mc.next_btn.onRelease = nextTrack; top_section_mc.buttons_mc.prev_btn.onRelease = prevTrack; information_mc.settings_mc.shuffle_btn.onRelease = shuffleClick; information_mc.settings_mc.repeat_btn.onRelease = repeatClick; if (no_continue != 1 || no_continue != true) { mysound.onSoundComplete = nextTrack; } top_section_mc.track_display_mc.loader_mc.time_bar_mc.useHandCursor = false; top_section_mc.track_display_mc.loader_mc.time_bar_mc.onPress = timeChange; top_section_mc.track_display_mc.loader_mc.time_bar_mc.onRelease = top_section_mc.track_display_mc.loader_mc.time_bar_mc.onReleaseOutside=function () { this._parent.onMouseMove = this._parent.onMouseUp=null; }; volume_mc.volume_btn.useHandCursor = false; volume_mc.volume_btn.onPress = volumeChange; volume_mc.volume_btn.onRelease = volume_mc.volume_btn.onReleaseOutside=function () { this._parent.onMouseMove = null; }; //VOLUME FUNCTION function volumeChange() { this._parent.onMouseMove = function() { var percent = (this._xmouse/this._width)*100; if (percent>100) { percent = 100; } if (percent<0) { percent = 0; } this.volume_bar_mc._xscale = percent; //Sets the Max level to half of input, creating less distortion with variable Mp3 files. var max_level = percent*0.5; this._parent.volume_level = max_level; }; } //FUNCTION TO ALLOW FOR USER TO SKIP TRACK ON TRACKLIST BAR function timeChange() { if (top_section_mc.play_mc._currentframe == 2) { if (play_type == 1) { var percent = (this._parent._xmouse/this._width); if (percent>100) { percent = 100; } if (percent<0) { percent = 0; } timePlace = (mysound.duration*percent)/1000; mysound.start(timePlace); this._parent.onMouseMove = function() { var percent = (this._parent._xmouse/this._width); if (percent>100) { percent = 100; } if (percent<0) { percent = 0; } timePlace = (mysound.duration*percent)/1000; mysound.start(timePlace); }; } else if (play_type == 2) { playin = 0; var percent = (this._parent._xmouse/this._width); if (percent>100) { percent = 100; } if (percent<0) { percent = 0; } top_section_mc.track_display_mc.loader_mc.time_bar_mc.time_count._xscale = percent*100; timePlace = (totalTime*percent); this._parent.onMouseMove = function() { playin = 0; var percent = (this._parent._xmouse/this._width); if (percent>100) { percent = 100; } if (percent<0) { percent = 0; } top_section_mc.track_display_mc.loader_mc.time_bar_mc.time_count._xscale = percent*100; timePlace = (totalTime*percent); }; this._parent.onMouseUp = function() { playin = 1; }; } } } //TIME AND TOTAL TIME DISPLAY - SET FOR MP3 FILES ONLY function timeDisplay() { //countup if (play_type == 1) { time = mysound.position/1000; } if (play_type == 1) { total_time = mysound.duration/1000; } //time calculations min = Math.floor(time/60); sec = Math.floor(time%60); sec = (sec<10) ? "0"+sec : sec; minT = Math.floor(total_time/60); secT = Math.floor(total_time%60); secT = (secT<10) ? "0"+secT : secT; total_time = minT+":"+secT; //text of time shown on player top_section_mc.time_mc.time_txt.text = min+":"+sec+"/"+total_time; } //STOP FUNCTION function stopTrack() { mysound.stop(); top_section_mc.play_mc.gotoAndStop(1); mysound.stop(); mysound.start(); mysound.stop(); _root.pause_position = 0; } //PLAY FUNCTION function playTrack() { if (top_section_mc.play_mc._currentframe == 1) { //play if (play_type == 1) { mysound.stop(); mysound.start(int((pause_position)/1000), 1); } top_section_mc.play_mc.gotoAndStop(2); } else if (top_section_mc.play_mc._currentframe == 2) { if (play_type == 1) { pause_position = mysound.position; mysound.stop(); } top_section_mc.play_mc.gotoAndStop(1); } } //NEXT TRACK FUNCTION function nextTrack() { playlist_mc.tracks_mc.track_0_mc["track_"+track_index+"_mc"].bg_mc.gotoAndStop(1); // Sets user auto color for playlist area auto_color(); /*Autoscroll Playlist Area Down*/ if (track_index+3>((Stage.height-16)/16) || track_index+4>((height-18)/16)) { scrollbar_mc.v = 1; scrollTracks(); } //REPEAT OPTION if (shuffle != 1 and repeat != 0) { mediaCheck(); if (repeat_playlist == 1 || repeat_playlist == true) { track_index = 0; } //SHUFFLE OPTION } else if (shuffle != 0 and repeat != 1) { mediaCheck(); //PLAY NEXT TRACK } else if (shuffle != 1 and repeat != 1) { if (track_index0) { track_index--; } } last_track_index = track_index; playlist_mc.tracks_mc.track_0_mc["track_"+track_index+"_mc"].bg_mc.gotoAndStop(1); // Sets user auto color for playlist area auto_color(); mediaCheck(); } //FUNCTION TO SCROLL TITLE IF TRACK INFO DOES NOT FIT TRACKLIST AREA function scrollTitle() { //Speed of scrolling text across Track area top_section_mc.track_display_mc.track_text_mc.display_txt._x -= 5; if (top_section_mc.track_display_mc.track_text_mc.display_txt._x+top_section_mc.track_display_mc.track_text_mc.display_txt._width<0) { top_section_mc.track_display_mc.track_text_mc.display_txt._x = top_section_mc.track_display_mc.track_text_mc.mask_mc._width; } } //PLAYER DIMENSIONS FOR .fla GRAPHICS AND HTML RESIZING function resizeUI() { // Sets value to true album_xml_jpg_data = 2; if (width || height) { top_section_mc.top_bg_mc._width = width-28; top_section_mc.track_display_mc.loader_mc._width = width-top_section_mc.track_display_mc._x-29; } else { top_section_mc.top_bg_mc._width = Stage.width-28; top_section_mc.track_display_mc.loader_mc._width = Stage.width-top_section_mc.track_display_mc._x-29; } // If time counter is turned off allow text to scroll across entire track display bar. if (display_time == 0) { top_section_mc.track_display_mc.track_text_mc.mask_mc._width = top_section_mc.track_display_mc.loader_mc._width-2; top_section_mc.time_mc._visible = false; } else { // Else just keep time counter and make text fit in track display bar. top_section_mc.time_mc._visible = true; top_section_mc.track_display_mc.track_text_mc.mask_mc._width = top_section_mc.track_display_mc.loader_mc._width-55; } checkTextwidth(); if (width || height) { // Adjusts player width and height according to user input via URL command. top_section_mc.top_bg_mc._width = width-28; top_section_mc.track_display_mc.loader_mc._width = width-top_section_mc.track_display_mc._x-29; start_btn_mc._xscale = width; top_section_mc.time_mc._x = width-70; volume_mc._x = width-25; cover_mc._y = 19; playlist_mc._x = 138; playlist_mc.mask_mc._y = 3; playlist_mc.tracks_mc._y = 1; playlist_mc.tracks_mc._x = cover_mc._x+2; scrollbar_mc._x = width-12; scrollbar_mc.bg_mc._height = height-18; playlist_mc.mask_mc._width = width-(playlist_mc._x+18); playlist_mc.bg_mc._width = width-(playlist_mc._x+14); playlist_mc.tracks_mc.track_0_mc.bg_mc._width = width-(playlist_mc._x+18); playlist_mc.tracks_mc.track_0_mc.bg_mc._height = 12; playlist_mc.bg_mc._height = height-18; playlist_mc.mask_mc._height = height-24.5; information_mc.info_text_mc._x = 35; information_mc._y = 153; information_mc.info_bg._width = 134; information_mc.settings_mc.shuffle_btn._x = 0; information_mc.settings_mc.repeat_btn._x = 100; if (height>250 || album == 0) { // Tall mode cover_mc._visible = false; album_xml_jpg_data = false; information_mc.info_bg._width = width-15; information_mc._y = height-18; scrollbar_mc.bg_mc._height = height-19; information_mc.settings_mc.shuffle_btn._x = 5; information_mc.settings_mc.repeat_btn._x = width-55; information_mc.info_text_mc._x = (information_mc.info_bg._width/2)-30; information_mc.information_btn._x = (information_mc.info_bg._width/2)-30; playlist_mc._x = cover_mc._x+1; playlist_mc.bg_mc._height = height-37; playlist_mc.mask_mc._height = height-43; playlist_mc.mask_mc._width = width-19; playlist_mc.bg_mc._width = width-15; } else if (height<20) { // Small mode cover_mc._visible = false; scrollbar_mc._visible = false; information_mc._visible = false; album_xml_jpg_data = false; playlist_mc._visible = false; } } else { // Automatically adjusts player width and height according to HTML resizing. if (Stage.height>2.9*134) { //IF PLAYER IS GREATER THAN 389 IN HEIGHT . . . //***** Stretch playlist area downward . ***** playlist_mc._x = cover_mc._x+1; /*Moves Playlist to Left with 1 pixel margin from left of window*/ scrollbar_mc.bg_mc._height = Stage.height; //***** Subtract height to accommodate bottom player controls.***** playlist_mc.bg_mc._height = Stage.height-37; playlist_mc.mask_mc._height = Stage.height-42; //***** Move Controls to bottom/remove album pics. ***** information_mc._y = Stage.height-18; cover_mc._visible = false; // Turns off album downloading to save Internet bandwidth. Since player has removed album area, album covers won't be seen. album_xml_jpg_data = false; information_mc.info_bg._width = Stage.width-15; //***** Move bottom controls towards center of bottom bar ***** information_mc.settings_mc.shuffle_btn._x = 5; information_mc.settings_mc.repeat_btn._x = Stage.width-55; information_mc.info_text_mc._x = (information_mc.info_bg._width/2)-30; information_mc.information_btn._x = (information_mc.info_bg._width/2)-30; } else { if (Stage.width<2.5*134) { //IF PLAYER IS GREATER THAN 335 IN WIDTH . . . //Moves controls to bottom and removes album area if width less than 335 information_mc._y = Stage.height-18; information_mc._visible = true; cover_mc._visible = false; // Turns off album downloading to save Internet bandwidth. Since player has removed album area, album covers won't be seen. album_xml_jpg_data = false; information_mc.info_bg._width = Stage.width-15; //Stretch playlist area downward if width is less than or 335. playlist_mc._x = cover_mc._x+1; scrollbar_mc.bg_mc._height = Stage.height; /*Subtract height to accommodate bottom player controls.*/ playlist_mc.bg_mc._height = Stage.height-37; playlist_mc.mask_mc._height = Stage.height-42; //Move bottom controls towards center information_mc.settings_mc.shuffle_btn._x = 5; information_mc.settings_mc.repeat_btn._x = Stage.width-55; information_mc.info_text_mc._x = (information_mc.info_bg._width/2)-30; information_mc.information_btn._x = (information_mc.info_bg._width/2)-30; } else { //IF PLAYER IS GREATER THAN 170 IN HEIGHT . . . //If album option is activated in URL, removes album area and moves bottom controls accordingly, //otherwise the resizing of player in HTML takes care of this. if (album == false) { information_mc._y = Stage.height-18; cover_mc._visible = false; information_mc._visible = true; information_mc.info_bg._width = Stage.width-15; playlist_mc._x = cover_mc._x+1; scrollbar_mc.bg_mc._height = Stage.height; information_mc.settings_mc.shuffle_btn._x = 5; information_mc.settings_mc.repeat_btn._x = Stage.width-55; information_mc.info_text_mc._x = (information_mc.info_bg._width/2)-30; information_mc.information_btn._x = (information_mc.info_bg._width/2)-30; playlist_mc.bg_mc._height = Stage.height-37; playlist_mc.mask_mc._height = Stage.height-42; album_xml_jpg_data = false; } else { cover_mc._visible = true; information_mc._visible = true; cover_mc._y = 19; information_mc.info_text_mc._x = 35; information_mc._y = 153; information_mc.info_bg._width = 134; information_mc.settings_mc.shuffle_btn._x = 0; information_mc.settings_mc.repeat_btn._x = 100; playlist_mc._x = 138; scrollbar_mc.bg_mc._height = Stage.height-19; playlist_mc.bg_mc._height = Stage.height-19; playlist_mc.mask_mc._height = Stage.height-25; } //IF PLAYER IS LESS THAN 170 IN HEIGHT . . . if (Stage.height<169) { information_mc.info_bg._width = Stage.width-15; information_mc._visible = true; information_mc._y = Stage.height-18; playlist_mc._x = cover_mc._x+1; scrollbar_mc.bg_mc._height = Stage.height; information_mc.settings_mc.shuffle_btn._x = 5; information_mc.settings_mc.repeat_btn._x = Stage.width-55; information_mc.info_text_mc._x = (information_mc.info_bg._width/2)-30; information_mc.information_btn._x = (information_mc.info_bg._width/2)-30; playlist_mc.bg_mc._height = Stage.height-37; playlist_mc.mask_mc._height = Stage.height-42; cover_mc._visible = false; album_xml_jpg_data = false; } } // If the player is being placed in Slim Mode remove bottom half of player (18 pixels in height). if (Stage.height<19) { information_mc._visible = false; // Turns off album downloading to save Internet bandwidth. Since player is in Slim Mode album covers won't be seen. album_xml_jpg_data = false; } } /*End of IF statements */ //Default dimensions/coordinates of player componants WITH OR WITHOUT being stretched start_btn_mc._xscale = Stage.width; top_section_mc.time_mc._x = Stage.width-70; volume_mc._x = Stage.width-25; playlist_mc.mask_mc._y = 3; playlist_mc.tracks_mc._y = 1; playlist_mc.tracks_mc._x = cover_mc._x+2; scrollbar_mc._x = Stage.width-12; //Stretch Playlist area to the right no matter what size playlist_mc.mask_mc._width = Stage.width-(playlist_mc._x+18); playlist_mc.bg_mc._width = Stage.width-(playlist_mc._x+14); playlist_mc.tracks_mc.track_0_mc.bg_mc._width = Stage.width-(playlist_mc._x+18); playlist_mc.tracks_mc.track_0_mc.bg_mc._height = 12; } } //Player adding tracks to playlist area function addTrack(track_label) { playlist_mc.tracks_mc.track_0_mc.attachMovie("track_item", "track_"+playlist_mc.track_count+"_mc", playlist_mc.track_count); import flash.filters.GlowFilter; var myGlow:GlowFilter = new GlowFilter(0x000000, 1, 0, 10, 0, 30); // Alpha2, Left&Right, Up&down, Alpha, ? if (blend == 1 || blend == 2) { playlist_mc.tracks_mc.track_0_mc["track_"+playlist_mc.track_count+"_mc"].bg_mc.filters = [myGlow]; } playlist_mc.tracks_mc.track_0_mc["track_"+playlist_mc.track_count+"_mc"]._y += playlist_mc.track_count*16; /*space between playlist tracks*/ playlist_mc.tracks_mc.track_0_mc["track_"+playlist_mc.track_count+"_mc"].track_display_text.display_txt.autoSize = "left"; playlist_mc.tracks_mc.track_0_mc["track_"+playlist_mc.track_count+"_mc"].track_display_text.display_txt.text = track_label; //Sets user text color text_color(); playlist_mc.tracks_mc.track_0_mc["track_"+playlist_mc.track_count+"_mc"].bg_mc._width = Stage.width-(playlist_mc._x+18); playlist_mc.tracks_mc.track_0_mc["track_"+playlist_mc.track_count+"_mc"].bg_mc.index = playlist_mc.track_count; // Sets user auto color for playlist area auto_color2(); // On track click move to that track playlist_mc.tracks_mc.track_0_mc["track_"+playlist_mc.track_count+"_mc"].bg_mc.select_btn.onPress = function() { playlist_mc.tracks_mc.track_0_mc["track_"+track_index+"_mc"].bg_mc.gotoAndStop(1); // Sets user auto color for playlist area auto_color(); last_track_index = track_index; playlist_mc.tracks_mc.track_0_mc["track_"+track_index+"_mc"].bg_mc.gotoAndStop(1); track_index = this._parent.index; songClick = 1; mediaCheck(); }; playlist_mc.track_count++; } //scroll mouseListener.onMouseWheel = function(wheel) { scrollbar_mc.v = (wheel/-3); scrollTracks(); }; scrollbar_mc.up_btn.onPress = function() { this._parent.v = -1; this._parent.onEnterFrame = scrollTracks; }; scrollbar_mc.down_btn.onPress = function() { this._parent.v = 1; this._parent.onEnterFrame = scrollTracks; }; scrollbar_mc.up_btn.onRelease = scrollbar_mc.down_btn.onRelease=function () { this._parent.onEnterFrame = null; }; scrollbar_mc.handler_mc.drag_btn.onPress = function() { var scroll_top_limit = 19; var scroll_bottom_limit = scrollbar_mc.bg_mc._height-scrollbar_mc.handler_mc._height-10; this._parent.startDrag(false, this._parent._x, scroll_top_limit, this._parent._x, scroll_bottom_limit); this._parent.isdragging = true; this._parent.onEnterFrame = scrollTracks; }; scrollbar_mc.handler_mc.drag_btn.onRelease = scrollbar_mc.handler_mc.drag_btn.onReleaseOutside=function () { stopDrag(); this._parent.isdragging = false; this._parent.onEnterFrame = null; }; function scrollTracks() { var scroll_top_limit = 19; var scroll_bottom_limit = scrollbar_mc.bg_mc._height-scrollbar_mc.handler_mc._height-10; var list_bottom_limit = 1; var list_top_limit = (1-Math.round(playlist_mc.tracks_mc._height))+Math.floor(playlist_mc.mask_mc._height/16)*16; if (playlist_mc.tracks_mc._height>playlist_mc.mask_mc._height) { if (scrollbar_mc.handler_mc.isdragging) { var percent = (scrollbar_mc.handler_mc._y-scroll_top_limit)/(scroll_bottom_limit-scroll_top_limit); playlist_mc.tracks_mc._y = (list_top_limit-list_bottom_limit)*percent+list_bottom_limit; } else { if (scrollbar_mc.v == -1) { if (playlist_mc.tracks_mc._y+16list_top_limit) { playlist_mc.tracks_mc._y -= 16; } else { playlist_mc.tracks_mc._y = list_top_limit; } var percent = (playlist_mc.tracks_mc._y-1)/(list_top_limit-1); scrollbar_mc.handler_mc._y = percent*(scroll_bottom_limit-scroll_top_limit)+scroll_top_limit; } else if (yPosition>1) { if (playlist_mc.tracks_mc._y-16top_section_mc.track_display_mc.track_text_mc.mask_mc._width) { top_section_mc.track_display_mc.track_text_mc.onEnterFrame = scrollTitle; } else { top_section_mc.track_display_mc.track_text_mc.onEnterFrame = null; top_section_mc.track_display_mc.track_text_mc.display_txt._x = 0; } } //first click - load playlist start_btn_mc.start_btn.onPress = function() { if (autoload == 1) { loadTrack(); } else { loadPlaylist(); autoplay = 1; } }; //Change Color of Player if (button_color) { button_color = button_color.toUpperCase(); hexChars = "0123456789ABCDEF"; red = "0x"+button_color.charAt(0)+button_color.charAt(1); grn = "0x"+button_color.charAt(2)+button_color.charAt(3); blu = "0x"+button_color.charAt(4)+button_color.charAt(5); /*Exact color from user input*/ var mybuttonColorTransform:Object = {ra:0, rb:red, ga:0, gb:grn, ba:0, bb:blu, aa:100, ab:0}; var mybuttonColorTransformLight:Object = {ra:0, rb:red-18, ga:-18, gb:grn, ba:-18, bb:blu, aa:100, ab:100}; shuffle_repeat_Color = new Color(information_mc.settings_mc); shuffle_repeat_Color.setTransform(mybuttonColorTransform); volume_button1 = new Color(volume_mc.volume_bar_mc); volume_button1.setTransform(mybuttonColorTransform); volume_button2 = new Color(volume_mc.gray_mc); volume_button2.setTransform(mybuttonColorTransformLight); track_buttons = new Color(top_section_mc.buttons_mc); track_buttons.setTransform(mybuttonColorTransform); play_button = new Color(top_section_mc.play_mc); play_button.setTransform(mybuttonColorTransform); scrollbar_button1 = new Color(scrollbar_mc.handler_mc); scrollbar_button1.setTransform(mybuttonColorTransform); scrollbar_button2 = new Color(scrollbar_mc.down_btn); scrollbar_button2.setTransform(mybuttonColorTransform); scrollbar_button3 = new Color(scrollbar_mc.up_btn); scrollbar_button3.setTransform(mybuttonColorTransform); } if (bg_color) { bg_color = bg_color.toUpperCase(); hexChars = "0123456789ABCDEF"; red = "0x"+bg_color.charAt(0)+bg_color.charAt(1); grn = "0x"+bg_color.charAt(2)+bg_color.charAt(3); blu = "0x"+bg_color.charAt(4)+bg_color.charAt(5); var myColorTransform:Object = {ra:0, rb:red, ga:0, gb:grn, ba:0, bb:blu, aa:100, ab:0}; /*Exact color from user input*/ var myColorTransform2:Object = {ra:8, rb:red, ga:8, gb:grn, ba:8, bb:blu, aa:100, ab:0}; /*Lighter Shade*/ var myColorTransform3:Object = {ra:-10, rb:red, ga:-10, gb:grn, ba:-10, bb:blu, aa:100, ab:0}; /*Darker Shade*/ var myColorTransform4:Object = {ra:-25, rb:red, ga:-25, gb:grn, ba:-25, bb:blu, aa:100, ab:0}; /*Darker Shadex2*/ //button color, off or on if (button_color) { } else { tracklist_D = new Color(top_section_mc.play_mc); tracklist_D.setTransform(myColorTransform4); tracklist_E = new Color(top_section_mc.buttons_mc); tracklist_E.setTransform(myColorTransform4); volume_btn_2 = new Color(volume_mc.gray_mc); volume_btn_2.setTransform(myColorTransform2); volume_btn_3 = new Color(volume_mc.volume_bar_mc); volume_btn_3.setTransform(myColorTransform4); scrollbar_btn1Color = new Color(scrollbar_mc.handler_mc); scrollbar_btn1Color.setTransform(myColorTransform4); scrollbar_btn2Color = new Color(scrollbar_mc.down_btn); scrollbar_btn2Color.setTransform(myColorTransform4); scrollbar_btn3Color = new Color(scrollbar_mc.up_btn); scrollbar_btn3Color.setTransform(myColorTransform4); information_buttonsColor = new Color(information_mc.settings_mc); information_buttonsColor.setTransform(myColorTransform4); } //Backgrounds tracklist_A = new Color(top_section_mc.track_display_mc.loader_mc.load_bar_mc); tracklist_A.setTransform(myColorTransform3); tracklist_B = new Color(top_section_mc.track_display_mc.loader_mc.time_bar_mc); tracklist_B.setTransform(myColorTransform2); tracklist_C = new Color(top_section_mc.top_bg_mc); tracklist_C.setTransform(myColorTransform); volume_btn_1 = new Color(volume_mc.bg_mc); volume_btn_1.setTransform(myColorTransform); scrollbar_bgColor = new Color(scrollbar_mc.bg_mc); scrollbar_bgColor.setTransform(myColorTransform); playlist_bg = new Color(playlist_mc.bg_mc); playlist_bg.setTransform(myColorTransform); cover_bgColor = new Color(cover_mc.border_mc); cover_bgColor.setTransform(myColorTransform); information_bgColor = new Color(information_mc.info_bg); information_bgColor.setTransform(myColorTransform); //Text if (txt_color) { } else { top_section_mc.track_display_mc.track_text_mc.blendMode = 3; top_section_mc.time_mc.blendMode = 3; information_mc.info_text_mc.blendMode = 3; cover_mc.photo_load_mc.blendMode = 3; } } if (txt_color) { txt_color = txt_color.toUpperCase(); hexChars = "0123456789ABCDEF"; red = "0x"+txt_color.charAt(0)+txt_color.charAt(1); grn = "0x"+txt_color.charAt(2)+txt_color.charAt(3); blu = "0x"+txt_color.charAt(4)+txt_color.charAt(5); /*Exact color from user input*/ var myTxtColor:Object = {ra:0, rb:red, ga:0, gb:grn, ba:0, bb:blu, aa:100, ab:0}; information_txtColor = new Color(information_mc.info_text_mc.player_info_text); information_txtColor.setTransform(myTxtColor); track_txtColor = new Color(top_section_mc.track_display_mc.track_text_mc.display_txt); track_txtColor.setTransform(myTxtColor); time_txtColor = new Color(top_section_mc.time_mc.time_txt); time_txtColor.setTransform(myTxtColor); load_album_txtColor = new Color(cover_mc.photo_load_mc.imageloadMC); load_album_txtColor.setTransform(myTxtColor); } if (blend == 1) { //MULTIPLY BLEND top_section_mc.blendMode = 3; playlist_mc.blendMode = 3; cover_mc.blendMode = 3; information_mc.blendMode = 3; scrollbar_mc.blendMode = 3; volume_mc.blendMode = 3; } if (blend == 2) { //OVERLAY BLEND top_section_mc.blendMode = 13; playlist_mc.blendMode = 13; cover_mc.blendMode = 13; information_mc.blendMode = 13; scrollbar_mc.blendMode = 13; volume_mc.blendMode = 13; } if (alpha) { //OVERLAY BLEND top_section_mc._alpha = alpha; playlist_mc._alpha = alpha; playlist_mc.tracks_mc.track_0_mc.bg_mc.track_light_mc._alpha = 0; playlist_mc.tracks_mc.track_0_mc.bg_mc.track_dark_mc._alpha = 0; if (blend == 1 || blend == 2) { } else { top_section_mc.track_display_mc.loader_mc.time_bar_mc._alpha = alpha-(alpha-70); } cover_mc._alpha = alpha; information_mc._alpha = alpha; scrollbar_mc._alpha = alpha; volume_mc._alpha = alpha; } // function to adjust user color to match background function auto_color() { playlist_l = new Color(playlist_mc.tracks_mc.track_0_mc["track_"+track_index+"_mc"].bg_mc.track_light_mc); playlist_l.setTransform(myColorTransform2); playlist_d = new Color(playlist_mc.tracks_mc.track_0_mc["track_"+track_index+"_mc"].bg_mc.track_dark_mc); playlist_d.setTransform(myColorTransform3); } function auto_color2() { playlist_l = new Color(playlist_mc.tracks_mc.track_0_mc["track_"+playlist_mc.track_count+"_mc"].bg_mc.track_light_mc); playlist_l.setTransform(myColorTransform2); playlist_d = new Color(playlist_mc.tracks_mc.track_0_mc["track_"+playlist_mc.track_count+"_mc"].bg_mc.track_dark_mc); playlist_d.setTransform(myColorTransform3); } function text_color() { if (txt_color) { playlist_txtColor = new Color(playlist_mc.tracks_mc.track_0_mc["track_"+playlist_mc.track_count+"_mc"].track_display_text.display_txt); playlist_txtColor.setTransform(myTxtColor); } else { if (bg_color) { playlist_mc.tracks_mc.track_0_mc["track_"+playlist_mc.track_count+"_mc"].track_display_text.blendMode = 3; } } } //********** XSPF FLASH MP3 ***********// // PLAYER BASIC SETTINGS // // // // // //**************************************// Stage.scaleMode = "noScale"; Stage.align = "LT"; this.onResize = resizeUI; Stage.addListener(this); Mouse.addListener(mouseListener); if (!player_title) { player_title = DEFAULT_WELCOME_MSG; } top_section_mc.track_display_mc.track_text_mc.display_txt.autoSize = "left"; top_section_mc.track_display_mc.track_text_mc.display_txt.text = player_title; checkTextwidth(); //start to play automatically if parameter autoplay is present if (autoplay == 1) { mediaCheck(); loadPlaylist(); // Removes Tracks area and Album cover area text (Will be turned back on when playlist loads successfully) cover_mc.photo_load_mc._visible = false; playlist_mc.tracks_mc._visible = false; } else if (autoload == 1) { loadPlaylist(); } //customized right-click menu var my_cm:ContextMenu = new ContextMenu(); my_cm.customItems.push(new ContextMenuItem("Play", playTrack)); my_cm.customItems.push(new ContextMenuItem("Stop", stopTrack)); my_cm.customItems.push(new ContextMenuItem("Next", nextTrack)); my_cm.customItems.push(new ContextMenuItem("Previous", prevTrack)); if (!menu) { my_cm.customItems.push(new ContextMenuItem("Download This Track", function () { getURL(playlist_array[track_index].location), "_blank"; }, true)); } else { my_cm.customItems.push(new ContextMenuItem("Download Option Disabled!", stopTrack, true)); } my_cm.hideBuiltInItems(); this.menu = my_cm; //Player Size or Resize resizeUI();