This is something you want to write long ago. It's only IEonly.
To control the width, height, and other attributes of the player, you can use lrcPlayer. getPlayer () to obtain the instance.
**************************************** ********
<Html>
<Title> real-time lrc lyrics playback </title>
<Body>
<Div id = "show" style = "background = black; font-size: 38px; text-align: center; height: 500px; line-height: 50px; overflow: auto; font-family: 文; color: white; "> </div>
<Style>
. RedLyric {font-size: 38px; font-weight: bold; color: red; font-family: 文 ;}
. NormalLyric {font-size: 38px; font-family: 文; color: white ;}
</Style>
<Script>
/*
========================================================== ==================================
Lrc lyrics play in real time
Non-mainstream fairy tales
Note: anyone can use this program and the author is not responsible for all consequences caused by the use of the program.
This section must be reprinted or modified.
========================================================== ==================================
*/
Var lrcPlayer = {
_ LrcUrl :"",
_ LrcSong :"",
_ LrcShower :"",
_ SongPlayer :"",
_ SongType :"",
_ NormalCss :"",
_ CurrentCss :"",
_ Singer :"",
_ SongTitle :"",
_ AlbumName :"",
_ LrcMaker :"",
_ Offset: 0,
_ TimeList: new Array (),
_ TextList: new Array (),
_ IntTimeList: new Array (),
_ TextJoiner: "<br/> ",
_ TextLrc :"",
_ CurrentKey: 0,
_ Interval: 100,
_ ErrorMsg: {'not _ ie': 'Non-ie browsers are not supported. 'Can _ not_get_lyric': "LRC lyrics cannot be downloaded "},
_ PrevLine :"",
_ PrevKey :"",
ShowError: function (showMessage, isEnd ){
Alert (showMessage );
If (isEnd) exit (0 );
},
IsIe: function (){
Return eval ("false;/* @ cc_on @ if (@ \ x5fwin32) isMSIE = true @ end @*/");
},
DownloadLrc: function (){
Document. body. addBehavior ("# default # download ");
Try {
_ This = this;
Document. body. startDownload (this. _ lrcUrl, function (lrcString) {_ this. startPlay (lrcString )});
}
Catch (exp ){
This. showError (this. _ errorMsg ["can_not_get_lyric"], 1 );
}
},
StartPlay: function (lrcString ){
This. splitLrcString (lrcString );
This. sortlclist ();
This. joinLrcText ();
This. showLrcText ();
_ This = this;
This. _ currentKey = 0;
SetInterval (function () {_ this. showCurrentLyric () ;}, this. _ interval );
},
ShowCurrentLyric: function (){
CurrentTime = this. getCurrentTime () + parseInt (this. _ offset );
This. seekLrcText (currentTime );
If (this. _ currentKey! = This. _ prevKey & this. _ currentKey> =-1 ){
CurrentKey = parseInt (this. _ currentKey );
FontSize = parseInt (this. _ lrcShower. style. fontSize. substr (0, this. _ lrcShower. style. fontSize. length-2 ));
LineHeight = parseInt (this. _ lrcShower. style. lineHeight. substr (0, this. _ lrcShower. style. lineHeight. length-2 ));
Space = lineHeight-fontSize;
This. _ lrcShower. scrollTop = currentKey * fontSize + (currentKey-1) * space;
CurrentLine = document. getElementById ("lyric" + currentKey );
CurrentLine. className = this. _ currentCss;
If (""! = This. _ prevLine ){
This. _ prevLine. className = this. _ normalCss;
}
This. _ prevLine = currentLine;
This. _ prevKey = this. _ currentKey;
}
},
GetCurrentTime: function (){
Player = this. getPlayer ();
Return player. controls. currentPosition * 1000;
},
UnsetList: function (list, n ){
If (n <0 ){
Return list;
}
Else {
Return list. slice (0, n). concat (list. slice (n + 1, list. length ));
}
},
SplitLrcString: function (lrcString ){
Var textList = lrcString. split (/\[.*? \]/);
Var timeList = lrcString. split (/\] [^ \ [] +/m );
Var deleteList = new Array ();
Var item = "";
Var tmp = "";
For (var I in timeList ){
If (/\ [ti:. */. test (timeList [I]) {
This. _ songTitle = timeList [I]. substr (4, timeList [I]. length-4 );
DeleteList. push (I );
}
Else if (/\ [ar:. */. test (timeList [I]) {
This. _ singer = timeList [I]. substr (4, timeList [I]. length-4 );
DeleteList. push (I );
}
Else if (/\ [al:. */. test (timeList [I]) {
This. _ albumName = timeList [I]. substr (4, timeList [I]. length-4 );
DeleteList. push (I );
}
Else if (/\ [by:. */. test (timeList [I]) {
This. _ lrcMaker = timeList [I]. substr (4, timeList [I]. length-4 );
DeleteList. push (I );
}
Else if (/\ [offset:. */. test (timeList [I]) {
This. _ offset = timeList [I]. substr (8, timeList [I]. length-4 );
DeleteList. push (I );
}
Else {
Item = timeList [I]. substr (1, timeList [I]. length-1 );
Tmp = item. split (/\] \ w? \[/);
If (tmp. length> 1 ){
Item = tmp [0];
For (j = 1; j <tmp. length; ++ j ){
TimeList. push (tmp [j]);
TextList. push (textList [I]);
}
}
TimeList [I] = item;
}
}
DeleteList = deleteList. sort ();
For (I = 0; I <deleteList. length; ++ I ){
TimeList = this. unsetList (timeList, deleteList [I]-I );
TextList = this. unsetList (textList, deleteList [I]-I );
}
This. _ timeList = timeList;
This. _ textList = textList;
},
Sortlclist: function (){
Var intTimeList = new Array ();
For (I = 0; I <this. _ timeList. length; ++ I ){
Min = this. _ timeList [I]. split (":");
Second = min [1]. split (".");
IntTimeList. push (parseInt (min [0] * 60000) + parseInt (second [0] * 1000) + parseInt (second [1]) * 1 );
}
For (I = 0; I <intTimeList. length-1; ++ I ){
For (j = I + 1; j <intTimeList. length; ++ j ){
If (intTimeList [I]> intTimeList [j]) {
Tmp = intTimeList [I];
IntTimeList [I] = intTimeList [j];
IntTimeList [j] = tmp;
Tmp = this. _ timeList [I];
This. _ timeList [I] = this. _ timeList [j];
This. _ timeList [j] = tmp;
Tmp = this. _ textList [I];
This. _ textList [I] = this. _ textList [j];
This. _ textList [j] = tmp;
}
}
}
This. _ intTimeList = intTimeList;
},
JoinLrcText: function (){
For (I =-5; I <0; ++ I ){
This. _ textLrc + = "<span id = 'lyric" + I + "'> & nbsp; </span>" + this. _ textJoiner;
}
For (I = 0; I <this. _ textList. length; ++ I ){
This. _ textLrc + = "<span id = 'lyric" + I + "'>" + this. _ textList [I] + "</span>" + this. _ textJoiner;
}
},
ShowLrcText: function (){
This. _ lrcShower. innerHTML = this. _ textLrc;
},
SeekLrcText: function (seekTime ){
This. _ currentKey = this. binarySearch (this. _ intTimeList, seekTime );
},
BinarySearch: function (list, seekTime ){
Start = 0;
Finish = list. length-1;
Mid = Math. floor (start + length)/2 );
While (start <= finish ){
If (seekTime = list [mid]) {
Return mid;
}
Else if (seekTime> list [mid]) {
Start = mid + 1;
}
Else {
Finish = mid-1;
}
Mid = Math. floor (start + finish)/2 );
}
Return mid;
},
InitSongPlayer: function (){
If (this. _ songType = "realplayer "){
Return this. initRealplayer ();
}
Else {
Return this. initMediaPlayer ();
}
},
InitRealplayer: function (){
Return true; // not implemented at the moment
},
InitMediaPlayer: function (){
Var playString = '<object classid = "clsid: 6BF52A52-394A-11D3-B153-00C04F79FAA6" id = "mediaPlayer" width = "250" height = "60"> ';
PlayString + = '<param name = "url" value = "' + this. _ lrcSong + '"> ';
PlayString + = '<param name = "rate" value = "1"> ';
PlayString + = '<param name = "balance" value = "0"> ';
PlayString + = '<param name = "currentPosition" value = "0"> ';
PlayString + = '<param name = "playCount" value = "9999"> ';
PlayString + = '<param name = "autoStart" value = "1"> ';
PlayString + = '<param name = "volume" value = "100"> ';
PlayString + = '<param name = "currentMarker" value = "0"> ';
PlayString + = '<param name = "invokeURLs" value = "-1"> ';
PlayString + = '<param name = "stretchToFit" value = "-1"> ';
PlayString + = '<param name = "windowlessVideo" value = "0"> ';
PlayString + = '<param name = "enabled" value = "-1"> ';
PlayString + = '<param name = "enableContextMenu" value = "0"> ';
PlayString + = '<param name = "fullScreen" value = "0"> ';
PlayString + = '<param name = "enableErrorDialogs" value = "0"> ';
PlayString + = '<param name = "AutoRewind" value = "1"> ';
PlayString + = '</object> ';
Document. body. insertAdjacentHTML ("beforeEnd", playString );
Return document. getElementById ("mediaPlayer ");
},
Init: function (lrcUrl, lrcSong, lrcShower, normalCss, currentCss, songType ){
If (! This. isIe () this. showError (this. _ errorMsg ["not_ie"], 1 );
This. _ lrcUrl = lrcUrl;
This. _ lrcSong = lrcSong;
This. _ lrcShower = document. getElementById (lrcShower );
This. _ songType = songType;
This. _ normalCss = normalCss;
This. _ currentCss = currentCss;
This. _ songPlayer = this. initSongPlayer ();
This. downloadLrc ();
},
GetPlayer: function (){
Return this. _ songPlayer;
}
}
LrcPlayer. init ("E:/Audio/song/Happy exercise/Zhou Chuanxiong-happy exercise. lrc "," E:/Audio/song/Happy exercise music/01.happy exercise music "," show "," normalLyric "," redLyric ");
</Script>
</Body>
</Html>