读书人

没分了,一flash播放器里程序不懂,哪位

发布时间: 2012-01-24 23:11:54 作者: rapoo

没分了,一flash播放器里程序不懂,谁能帮注解下??
function initPreferences()
{
if (preferences.data.musicOn == undefined)
{
preferences.data.musicOn = true;
} // end if
changePreferenceMusicOn(preferences.data.musicOn);
} // End of the function
function changePreferenceMusicOn(val)
{
musicOn = val;
preferences.data.musicOn = val;
preferences.data.flush();
} // End of the function
function initPlayer()
{
initPreferences();
initSound();
resetPositionIndicator();
assignButtons();
if (musicOn == true)
{
playSong();
disableButton(play_mc);
enableButton(pause_mc);
enableButton(stop_mc);
}
else
{
stopSong();
enableButton(play_mc);
disableButton(stop_mc);
disableButton(pause_mc);
} // end if
} // End of the function
function initSound()
{
song = new Sound(_root);
} // End of the function
function loadSong()
{
song.loadSound(playlist[currentSong].url, true);
loadingIndicator_mc.onEnterFrame = function ()
{
var _l2 = song.getBytesLoaded();
var _l3 = playlist[currentSong].filesize;
loadingIndicator_mc.loadingBar_mc._width = Number(_l2 / _l3 * loadingBarWidth);
if (_l2 == _l3)
{
delete this[ "onEnterFrame "];
} // end if
};
} // End of the function
function playSong()
{
if (song.getBytesLoaded() > = 0)
{
loadSong();
} // end if


if (playerPaused == true)
{
song.start(positionPaused / 1000, 1);
}
else
{
song.start(0, 1);
} // end if
startPositionIndicator();
playerStopped = false;
playerPaused = false;
showSongInfo();
} // End of the function
function stopSong()
{
song.stop();
playerStopped = true;
showSongInfo();
stopPositionIndicator();
resetPositionIndicator();
} // End of the function
function pauseSong()
{
positionPaused = song.position;
song.stop();
playerPaused = true;
showSongInfo();
stopPositionIndicator();
} // End of the function
function nextSong()
{
song.stop();
currentSong++;
if (currentSong > playlist.length - 1)
{
currentSong = 0;
} // end if
initSound();
loadSong();
playSong();
} // End of the function
function previousSong()
{
song.stop();
currentSong--;
if (currentSong < 0)
{
currentSong = playlist.length - 1;
} // end if
initSound();
loadSong();
playSong();
} // End of the function
function showSongInfo()
{
if (playerPaused == true)
{
songInfo_txt.text = "Paused ";
}
else if (playerStopped == true)
{
songInfo_txt.text = "Stopped ";
}
else
{
songInfo_txt.text = playlist[currentSong].artist + " - " + playlist[currentSong].title;


} // end if
if (songInfo_txt.maxscroll > 1)
{
startSongInfoScroll();
}
else
{
stopSongInfoScroll();
} // end if
} // End of the function
function startSongInfoScroll()
{
songScrollTime = 0;
lastSongScrollTime = 0;
songInfoScroll_mc.onEnterFrame = function ()
{
if (songScrollTime == lastSongScrollTime + 20)
{
lastSongScrollTime = songScrollTime;
songInfo_txt.scroll = songScrollTime / 20;
} // end if
if (songScrollTime == lastSongScrollTime + 16)
{
songScrollTransition_mc.gotoAndPlay(1);
} // end if
if (songScrollTime < songInfo_txt.maxscroll * 20)
{
songScrollTime++;
}
else
{
songScrollTime = 0;
lastSongScrollTime = 0;
} // end if
};
} // End of the function
function stopSongInfoScroll()
{
delete songInfoScroll_mc[ "onEnterFrame "];
} // End of the function
function resetPositionIndicator()
{
positionIndicator_mc._x = loadingIndicator_mc._x - positionIndicator_mc._width / 2;
positionIndicator_mc._y = loadingIndicator_mc._y + loadingIndicator_mc._height + positionIndicatorOffset;
} // End of the function
function startPositionIndicator()
{
positionIndicator_mc.onEnterFrame = function ()
{


var _l3 = song.position;
var _l2 = playlist[currentSong].duration;
positionIndicator_mc._x = loadingIndicator_mc._x - positionIndicator_mc._width / 2 + _l3 / _l2 * loadingBarWidth;
if (_l3 > = _l2)
{
delete this[ "onEnterFrame "];
resetPositionIndicator();
nextSong();
} // end if
};
} // End of the function
function stopPositionIndicator()
{
delete positionIndicator_mc[ "onEnterFrame "];
} // End of the function
function disableButton(obj)
{
obj.btn.enabled = false;
obj._alpha = 50;
} // End of the function
function enableButton(obj)
{
obj.btn.enabled = true;
obj._alpha = 100;
} // End of the function
function assignButtons()
{
play_mc.btn.onRelease = function ()
{
playSong();
disableButton(play_mc);
enableButton(stop_mc);
enableButton(pause_mc);
changePreferenceMusicOn(true);
};
pause_mc.btn.onRelease = function ()
{
pauseSong();
disableButton(pause_mc);
disableButton(stop_mc);
enableButton(play_mc);
changePreferenceMusicOn(true);
};
stop_mc.btn.onRelease = function ()
{
stopSong();
disableButton(stop_mc);
disableButton(pause_mc);
enableButton(play_mc);
changePreferenceMusicOn(false);
};
previous_mc.btn.onRelease = function ()


{
previousSong();
disableButton(play_mc);
enableButton(stop_mc);
enableButton(pause_mc);
changePreferenceMusicOn(true);
};
next_mc.btn.onRelease = function ()
{
nextSong();
disableButton(play_mc);
enableButton(stop_mc);
enableButton(pause_mc);
changePreferenceMusicOn(true);
};
popup_btn.onRelease = function ()
{
stopSong();
disableButton(stop_mc);
disableButton(pause_mc);
enableButton(play_mc);
getURL( "javascript:j_popup_music_player(\ ' " + _root.mpl + "\ '); ", " ");
};
} // End of the function
test_txt.text = "t " + _root.mpl;
_songbuftime = 2;
var playlistXML = new XML();
var playlist = new Array();
var playerPaused = false;
var playerStopped = false;
var currentSong = 0;
var song;
var positionPaused;
var loadingBarWidth = 100;
var positionIndicatorOffset = 2;
var preferences = SharedObject.getLocal( "NSMusicPlayerPreferencesObject ");
var musicOn = true;
var songScrollTime = 0;
var lastSongScrollTime = 0;
playlistXML.ignoreWhite = true;
playlistXML.onLoad = function ()
{
var _l2 = 0;
while (_l2 < this.firstChild.childNodes.length)
{
playlist[_l2] = new Object();
playlist[_l2].title = this.firstChild.childNodes[_l2].attributes.title;
playlist[_l2].artist = this.firstChild.childNodes[_l2].attributes.artist;
playlist[_l2].duration = Number(this.firstChild.childNodes[_l2].attributes.duration);
playlist[_l2].filesize = Number(this.firstChild.childNodes[_l2].attributes.filesize);
playlist[_l2].url = this.firstChild.childNodes[_l2].firstChild.nodeValue;


if (_l2 == this.firstChild.childNodes.length - 1)
{
initPlayer();
} // end if
_l2++;
} // end while
};
playlistXML.load( "/flash/ " + _root.mpl + ".xml ");
if (_root.popup != undefined)
{
popup_btn._visible = false;
} // end if
stop();

上以是写在FLASH播放器里的代码,大多看不到懂,可以帮注解下吗,
还有那页面里要怎么写,播放歌曲的文件是放在哪的,格式也不知道,哪位好人帮讲解下哦,呵呵!!

[解决办法]
好复杂啊,帮顶

读书人网 >.NET

热点推荐