This is useful also if you which to display your lyrics in MM using my Inline Lyrics script.
As always, there is an installation package available on my website, and the code can be found below...
Code: Select all
'
' MediaMonkey Script
'
' NAME: LyricTimer 4.0
'
' AUTHOR: trixmoto (http://trixmoto.net)
' DATE : 03/08/2014
'
' INSTALL: Copy to Scripts directory and add the following to Scripts.ini
' Don't forget to remove comments (') and set the order appropriately
'
' Thanks to Begges for his EvilTagger script which helped with importing from EvilLyrics
'
' FIXES: Updated for MM4 with new installation package
' Updated output to be HTML5 and moved to %temp%
' Fixed loop option by switching off crossfade
' Added option to auto-scroll down the page
'
' [LyricTimer]
' FileName=LyricTimer.vbs
' ProcName=LyricTimer
' Order=17
' DisplayName=Lyric Timer
' Description=Add timings to lyrics
' Language=VBScript
' ScriptType=0
'
Option Explicit
Public styleOn
Dim OddColour : OddColour = "#FFFFFF" 'white
Dim EvenColour : EvenColour = "#EFEFEF" 'silver
Dim TextColour : TextColour = "#000000" 'black
Dim HighlightColour : HighlightColour = "#FFFF77" 'yellow
Dim EvilLyrics : EvilLyrics = "C:\Program Files\EvilLyrics\lyrics\" 'leave blank if you don't want this feature
Dim RecheckSecs : RecheckSecs = 5 'number of seconds before rechecking EvilLyrics
Dim AutoScroll : AutoScroll = True 'scroll window so that current line stays in view
Sub LyricTimer
Dim Form : Set Form = SDB.Objects("LyricTimer")
If Form Is Nothing Then
Set Form = SDB.UI.NewDockablePersistentPanel("LyricPanel")
If Form.IsNew Then
Form.DockedTo = 2
Form.Common.Width = 250
End If
Form.Caption = "Lyric Timer"
Dim Head : Set Head = SDB.UI.NewPanel(Form)
Head.Common.Align = 1
Head.Common.Height = 25
Dim Btn1 : Set Btn1 = SDB.UI.NewButton(Head)
Btn1.Caption = "Revert back"
Btn1.Common.Height = 25
Btn1.Common.Width = 100
Btn1.Common.Left = 0
Btn1.UseScript = Script.ScriptPath
Btn1.OnClickFunc = "BackClick"
Dim Btn2 : Set Btn2 = SDB.UI.NewButton(Head)
Btn2.Caption = "Save changes"
Btn2.Common.Height = 25
Btn2.Common.Width = 100
Btn2.Common.Left = 100
Btn2.UseScript = Script.ScriptPath
Btn2.OnClickFunc = "SaveClick"
Dim Btn3 : Set Btn3 = SDB.UI.NewButton(Head)
Btn3.Caption = "Loop: No"
Btn3.Common.ControlName = "Btn3"
Btn3.Common.Height = 25
Btn3.Common.Width = 100
Btn3.Common.Left = 200
Btn3.UseScript = Script.ScriptPath
Btn3.OnClickFunc = "LoopClick"
Dim WB : Set WB = SDB.UI.NewActiveX(Form, "Shell.Explorer")
WB.Common.Align = 5
WB.Common.ControlName = "WB"
WB.Interf.Navigate "about:"
SDB.Objects("LyricWB") = WB.Interf
SDB.Objects("LyricDoc") = WB.Interf.Document
Else
If Form.Common.Visible Then
Form.Common.Visible = False
Exit Sub
Else
Dim WB_Interf : Set WB_Interf = SDB.Objects("LyricWB")
Call WB_Interf.Navigate("about:")
End If
End If
Dim vars : Set vars = CreateObject("Scripting.Dictionary")
vars.Item("classname") = "dark"
vars.Item("curr") = 0
vars.Item("isong") = -1
vars.Item("trax") = 0
Form.Common.Visible = True
Set SDB.Objects("LyricTimer") = Form
Set SDB.Objects("LyricData") = Nothing
Set SDB.Objects("LyricVars") = vars
Dim Tmr : Set Tmr = SDB.CreateTimer(100)
Call Script.RegisterEvent(Tmr,"OnTimer","Update")
End Sub
Sub Update(Timer)
'update track list
Dim vars : Set vars = SDB.Objects("LyricVars")
Dim song : Set song = SDB.Player.CurrentSong
If song Is Nothing Then
If Not (vars.Item("classname") = "nosong") Then
vars.Item("classname") = "nosong"
vars.Item("curr") = 0
vars.Item("isong") = -1
vars.Item("trax") = 0
Set SDB.Objects("LyricData") = Nothing
Set SDB.Objects("LyricVars") = vars
Call writedocument()
End If
Else
If Not (song.ID = Int(vars.Item("isong"))) Then
vars.Item("classname") = "dark"
vars.Item("curr") = 0
vars.Item("isong") = song.ID
vars.Item("trax") = extractlyrics()
If SDB.Player.isCrossfade Then
SDB.Player.isCrossfade = False
vars.Item("crossfade") = 1
Else
If Not (vars.Exists("crossfade")) Then
vars.Item("crossfade") = 0
End If
End If
Set SDB.Objects("LyricVars") = vars
Call writedocument()
Else
Dim Data : Set Data = SDB.Objects("LyricData")
If Not (Data Is Nothing) Then
If Not (Data.Item("rewrite") = "") Then
If Data.Item("rewrite") = "insert" Then
vars.Item("trax") = Int(vars.Item("trax"))+1
Else
vars.Item("trax") = Int(vars.Item("trax"))-1
End If
Set SDB.Objects("LyricVars") = vars
Call writedocument()
Data.Item("rewrite") = ""
Set SDB.Objects("LyricData") = Data
End If
End If
End If
End If
'update track highlight
If Int(vars.Item("trax")) > 0 Then
Dim doc : Set doc = SDB.Objects("LyricDoc")
If Not (doc Is Nothing) Then
Dim row : Set row = Nothing
Dim newcurr : newcurr = getcurr()
Dim curr : curr = Int(vars.Item("curr"))
If newcurr = curr Then
Set row = doc.getElementById("row"&curr)
If Not (row Is Nothing) Then
row.className = "highlight"
End If
Else
If curr > 0 Then
doc.getElementById("row"&curr).className = vars.Item("classname")
End If
Set row = doc.getElementById("row"&newcurr)
If Not (row Is Nothing) Then
vars.Item("classname") = row.className
row.className = "highlight"
vars.Item("curr") = newcurr
Set SDB.Objects("LyricVars") = vars
End If
End If
End If
End If
'loop song
Dim Form : Set Form = SDB.Objects("LyricTimer")
If Not (Form Is Nothing) Then
If Form.Common.Visible Then
If SDB.Player.CurrentSongLength > 0 Then
Dim Btn : Set Btn = Form.Common.ChildControl("Btn3")
If Btn.Caption = "Loop: Yes" Then
Dim diff : diff = SDB.Player.CurrentSong.StopTime - SDB.Player.PlaybackTime
If diff < 5000 Then
SDB.Player.PlaybackTime = SDB.Player.CurrentSong.StartTime
End If
End If
End If
Else 'stop when hidden
Call Script.UnregisterAllEvents()
If Int(vars.Item("crossfade")) = 1 Then
SDB.Player.isCrossfade = True
End If
End If
Else
Call Script.UnregisterAllEvents()
If Int(vars.Item("crossfade")) = 1 Then
SDB.Player.isCrossfade = True
End If
End If
End Sub
Function getcurr()
getcurr = 1
Dim Data : Set Data = SDB.Objects("LyricData")
Do While getcurr < 100
Dim indx : indx = Data.Item("time"&(getcurr+1))
If Not (indx = "") Then
If SDB.Player.PlaybackTime >= CLng(indx) Then
getcurr = getcurr+1
Else
Exit Do
End If
Else
Exit Do
End If
Loop
End Function
Function settime(lng)
Dim min,sec,hun,tint
tint = lng\60000
If tint < 10 Then
min = "0"&tint
Else
min = ""&tint
End If
lng = lng - (tint*60000)
tint = lng\1000
If tint < 10 Then
sec = "0"&tint
Else
sec = ""&tint
End If
lng = lng - (tint*1000)
tint = lng\10
If tint < 10 Then
hun = "0"&tint
Else
hun = ""&tint
End If
lng = lng - (tint*10)
settime = "["&min&":"&sec&"."&hun&"]"
End Function
Function gettime(txt)
Dim min,sec,hun,temp
If Len(txt) = 8 Then
temp = Mid(txt,1,2)
If isNumeric(temp) Then min = Clng(temp)
temp = Mid(txt,4,2)
If isNumeric(temp) Then sec = Clng(temp)
temp = Mid(txt,7,2)
If isNumeric(temp) Then hun = Clng(temp)
End If
gettime = min*60000 + sec*1000 + hun*10
End Function
Function simplify(txt)
Dim a : a = InStr(txt,"<")
If a = 0 Then
simplify = txt
Exit Function
End If
Dim b : b = InStr(txt,">")
If b = 0 Then b = a
Dim l : l = Len(txt)
Dim c : c = Mid(txt,1,a-1)
Dim d : d = Mid(txt,b+1,l-b)
txt = c&d
a = InStr(txt,"<")
If a > 0 Then txt = simplify(txt)
simplify = txt
End Function
Function MapXML(original)
Dim hold : hold = original
hold = Replace(hold,"&","&")
hold = Replace(hold," "," ")
hold = Replace(hold,"<","<")
hold = Replace(hold,">",">")
Dim i : i = 1
While i<=Len(hold)
If (AscW(Mid(hold, i, 1))>127) Then
hold = Mid(hold, 1, i-1)+"&#"+CStr(AscW(Mid(hold, i, 1)))+";"+Mid(hold, i+1)
End If
i = i+1
Wend
MapXML = hold
End Function
Function Style()
styleOn = Not styleOn
If styleOn Then
Style = " class=""dark"""
Else
Style = ""
End If
End Function
Function extractlyrics()
Dim Data : Set Data = CreateObject("Scripting.Dictionary")
Dim song : Set song = SDB.Player.CurrentSong
Dim lrc : lrc = song.Lyrics
Dim trax : trax = 0
'import from EvilLyrics
If (lrc = "") And (EvilLyrics <> "") Then
If Not (Right(EvilLyrics,1) = "\") Then
EvilLyrics = EvilLyrics&"\"
End If
Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
Dim cap : cap = UCase(Left(song.ArtistName,1))
If InStr("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",cap) = 0 Then
cap = "_"
End If
Dim art : art = correctfilename(song.ArtistName)
Dim tit : tit = correctfilename(song.Title)
cap = EvilLyrics&cap&"\"&art&" - "&tit&".txt"
If fso.FileExists(cap) Then
Dim fil : Set fil = fso.OpenTextFile(cap, 1, False)
Do While Not fil.AtEndOfStream
If lrc = "" Then
lrc = fil.ReadLine
Else
lrc = lrc&VbCrLf&fil.ReadLine
End If
Loop
Else
Dim Tmr : Set Tmr = SDB.CreateTimer(RecheckSecs*1000)
Call Script.RegisterEvent(Tmr,"OnTimer","Recheck")
End If
End If
'read lyrics
If lrc <> "" Then
Dim ina : ina = split(lrc,VbCrLf)
Dim inp : inp = 0
Dim str,pos,cur,txt
If Left(ina(inp),4) = "[ti:" Then
str = Mid(ina(inp),5,Len(ina(inp))-5)
inp = inp+1
Else
str = song.Title
End If
Data.Add "title", str
If Left(ina(inp),4) = "[ar:" Then
str = Mid(ina(inp),5,Len(ina(inp))-5)
inp = inp+1
Else
str = song.ArtistName
End If
Data.Add "artist", str
If Left(ina(inp),4) = "[au:" Then
str = Mid(ina(inp),5,Len(ina(inp))-5)
inp = inp+1
Else
str = song.Author
End If
Data.Add "author", str
If Left(ina(inp),4) = "[al:" Then
str = Mid(ina(inp),5,Len(ina(inp))-5)
inp = inp+1
Else
str = song.AlbumName
End If
Data.Add "album", str
If Left(ina(inp),4) = "[ve:" Then
str = Mid(ina(inp),5,Len(ina(inp))-5)
inp = inp+1
Else
str = "1.0"
End If
Data.Add "version", str
For pos = inp To UBound(ina)
trax = pos-inp+1
If Len(ina(pos)) < 10 Then
Data.Add "time"&trax, "0"
Data.Add "line"&trax, ina(pos)
Else
If (Left(ina(pos),1) = "[") And (Mid(ina(pos),10,1) = "]") Then
str = gettime(Mid(ina(pos),2,8))
Data.Add "time"&trax, str
str = Mid(ina(pos),11)
Data.Add "line"&trax, str
Else
Data.Add "time"&trax, "0"
Data.Add "line"&trax, ina(pos)
End If
End If
Next
End If
Set SDB.Objects("LyricData") = Data
extractlyrics = trax
End Function
Function correctfilename(str)
Dim i,cap
For i = 1 To Len(str)
cap = Mid(str,i,1)
If InStr("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789. ",UCase(cap)) = 0 Then
cap = "_"
End If
correctfilename = correctfilename&cap
Next
End Function
Sub Recheck(Timer)
Call Script.UnregisterEvents(Timer)
Dim vars : Set vars = SDB.Objects("LyricVars")
vars.Item("isong") = -1
Set SDB.Objects("LyricVars") = vars
End Sub
Sub writedocument()
Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
Dim loc : loc = SDB.TemporaryFolder&"LyricTimer.htm"
Dim doc : Set doc = fso.CreateTextFile(loc,True)
Dim Data : Set Data = SDB.Objects("LyricData")
Dim vars : Set vars = SDB.Objects("LyricVars")
Dim trax : trax = Int(vars.Item("trax"))
Dim wb : Set wb = SDB.Objects("LyricWB")
Call wb.Navigate("about:")
styleOn = False
doc.WriteLine "<!doctype html>"
doc.WriteLine "<html>"
doc.WriteLine " <head>"
doc.WriteLine " <title>"&SDB.Localize("Lyric Timer")&"</title>"
doc.WriteLine " <style type=""text/css"">"
doc.WriteLine " body{font-family:'Verdana',sans-serif; background-color:"&OddColour&"; font-size:9pt; color:"&TextColour&";}"
doc.WriteLine " p{font-family:'Verdana',sans-serif; font-size:8pt; color:"&TextColour&";}"
doc.WriteLine " th{font-family:'Verdana',sans-serif; font-size:9pt; font-weight:bold; color:"&TextColour&"; border-color:"&TextColour&"; border-style: solid; border-left-width:0px; border-right-width:0px; border-top-width:0px; border-bottom-width:3px;}"
doc.WriteLine " td{font-family:'Verdana',sans-serif; font-size:8pt; color:"&TextColour&"; border-color:"&TextColour&"; border-style: solid; border-left-width:0px; border-right-width:0px; border-top-width:0px; border-bottom-width:1px;}"
doc.WriteLine " tr.highlight{background-color:"&HighlightColour&"}"
doc.WriteLine " tr.dark{background-color:"&EvenColour&"}"
doc.WriteLine " tr.aleft th{text-align:left}"
doc.WriteLine " </style>"
doc.WriteLine " <script type=""text/javascript"">"
If AutoScroll Then
doc.WriteLine " function scrollpage() {"
doc.WriteLine " var col = document.getElementsByClassName(""highlight"");"
doc.WriteLine " if(col.length==1) {"
doc.WriteLine " var el = col[0];"
doc.WriteLine " var topOfPage = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;"
doc.WriteLine " var heightOfPage = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;"
doc.WriteLine " var elY = 0;"
doc.WriteLine " for(var p=el; p&&p.tagName!='BODY'; p=p.offsetParent) {"
doc.WriteLine " elY += p.offsetTop;"
doc.WriteLine " }"
doc.WriteLine " var elH = el.offsetHeight;"
doc.WriteLine " if ((topOfPage + heightOfPage) < (elY + elH)) {"
doc.WriteLine " el.scrollIntoView(false);"
doc.WriteLine " }"
doc.WriteLine " else if (elY < topOfPage) {"
doc.WriteLine " el.scrollIntoView(true);"
doc.WriteLine " }"
doc.WriteLine " }"
doc.WriteLine " setTimeout(""scrollpage();"",1000);"
doc.WriteLine " }"
doc.WriteLine " setTimeout(""scrollpage();"",1000);"
End If
If (trax < 1) And (EvilLyrics <> "") Then
doc.WriteLine " var cursec = "&RecheckSecs&";"
doc.WriteLine " function countdown() {"
doc.WriteLine " cursec--;"
doc.WriteLine " document.getElementById(""secs"").innerHTML = cursec;"
doc.WriteLine " if ( cursec > 0 ) {"
doc.WriteLine " setTimeout(""countdown();"",1000);"
doc.WriteLine " }"
doc.WriteLine " }"
doc.WriteLine " setTimeout(""countdown();"",1000);"
End If
doc.WriteLine " </script>"
doc.WriteLine " <script type=""text/vbscript"">"
doc.WriteLine " Dim SDB : Set SDB = CreateObject(""SongsDB.SDBApplication"")"
doc.WriteLIne " Dim trax : trax = "&trax
doc.WriteLine " Function gotopos(i)"
doc.WriteLine " Dim Data : Set Data = SDB.Objects(""LyricData"")"
doc.WriteLine " Data.Item(""time""&i) = SDB.Player.PlaybackTime"
doc.WriteLine " document.getElementById(""span""&i).innerHTML = settime(Data.Item(""time""&i))"
doc.WriteLine " SDB.Objects(""LyricsData"") = Data"
doc.WriteLine " End Function"
doc.WriteLine " Function settime(lng)"
doc.WriteLine " Dim min,sec,hun,tint"
doc.WriteLine " tint = lng\60000"
doc.WriteLine " If tint < 10 Then "
doc.WriteLine " min = ""0""&tint"
doc.WriteLine " Else"
doc.WriteLine " min = """"&tint"
doc.WriteLine " End If "
doc.WriteLine " lng = lng - (tint*60000)"
doc.WriteLine " tint = lng\1000"
doc.WriteLine " If tint < 10 Then"
doc.WriteLine " sec = ""0""&tint"
doc.WriteLine " Else"
doc.WriteLine " sec = """"&tint"
doc.WriteLine " End If"
doc.WriteLine " lng = lng - (tint*1000)"
doc.WriteLine " tint = lng\10"
doc.WriteLine " If tint < 10 Then"
doc.WriteLine " hun = ""0""&tint"
doc.WriteLine " Else"
doc.WriteLine " hun = """"&tint"
doc.WriteLine " End If"
doc.WriteLine " lng = lng - (tint*10)"
doc.WriteLine " settime = ""[""&min&"":""&sec&"".""&hun&""]"""
doc.WriteLine " End Function"
doc.WriteLine " Function addline(i)"
doc.WriteLine " Dim Data : Set Data = SDB.Objects(""LyricData"")"
doc.WriteLine " For j = trax To i+1 Step -1"
doc.WriteLine " Data.Item(""time""&(j+1)) = Data.Item(""time""&j)"
doc.WriteLine " Data.Item(""line""&(j+1)) = Data.Item(""line""&j)"
doc.WriteLine " Next"
doc.WriteLine " Data.Item(""time""&(i+1)) = 0"
doc.WriteLine " Data.Item(""line""&(i+1)) = """""
doc.WriteLine " Data.Item(""rewrite"") = ""insert"""
doc.WriteLine " SDB.Objects(""LyricsData"") = Data"
doc.WriteLine " End Function"
doc.WriteLine " Function editline(i)"
doc.WriteLine " Dim Data : Set Data = SDB.Objects(""LyricData"")"
doc.WriteLine " Dim str : str = InputBox(""Line:"",""Lyric Timer"",Data.Item(""line""&i))"
doc.WriteLine " Data.Item(""line""&i) = str"
doc.WriteLine " document.getElementById(""line""&i).innerHTML = simplify(str)"
doc.WriteLine " SDB.Objects(""LyricsData"") = Data"
doc.WriteLine " End Function"
doc.WriteLine " Function deleteline(i)"
doc.WriteLine " Dim Data : Set Data = SDB.Objects(""LyricData"")"
doc.WriteLine " For j = i To trax-1"
doc.WriteLine " Data.Item(""time""&j) = Data.Item(""time""&(j+1))"
doc.WriteLine " Data.Item(""line""&j) = Data.Item(""line""&(j+1))"
doc.WriteLine " Next"
doc.WriteLine " Data.Item(""time""&trax) = """""
doc.WriteLine " Data.Item(""line""&trax) = """""
doc.WriteLine " Data.Item(""rewrite"") = ""delete"""
doc.WriteLine " SDB.Objects(""LyricsData"") = Data"
doc.WriteLine " End Function"
doc.WriteLine " Function simplify(txt)"
doc.WriteLine " Dim a : a = InStr(txt,""<"")"
doc.WriteLine " If a = 0 Then"
doc.WriteLine " simplify = txt"
doc.WriteLine " Exit Function"
doc.WriteLine " End If"
doc.WriteLine " Dim b : b = InStr(txt,"">"")"
doc.WriteLine " If b = 0 Then b = a"
doc.WriteLine " Dim l : l = Len(txt)"
doc.WriteLine " Dim c : c = Mid(txt,1,a-1)"
doc.WriteLine " Dim d : d = Mid(txt,b+1,l-b)"
doc.WriteLine " txt = c&d"
doc.WriteLine " a = InStr(txt,""<"")"
doc.WriteLine " If a > 0 Then txt = simplify(txt)"
doc.WriteLine " simplify = txt"
doc.WriteLine " End Function"
doc.WriteLine " </script>"
doc.WriteLine " </head>"
doc.WriteLine " <body>"
doc.WriteLine " <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">"
doc.WriteLine " <tr class=""aleft"">"
doc.WriteLine " <th> </th>"
doc.WriteLine " <th>"&SDB.Localize("Timestamp")&"</th>"
doc.WriteLine " <th>"&SDB.Localize("Line")&"</th>"
doc.WriteLine " <th><a href=""vbscript:addline(0)"">Add first</a></th>"
doc.WriteLine " </tr>"
If trax > 0 Then
Dim i,line
For i = 1 To trax
line = simplify(Data.Item("line"&i))
If line = "" Then line = " "
doc.WriteLine " <tr id=""row"&i&""""&Style()&">"
doc.WriteLine " <td nowrap><a href=""vbscript:gotopos("&i&")"">Line "&i&"</a></td>"
doc.WriteLine " <td nowrap><span id=""span"&i&""">"&MapXML(settime(Data.Item("time"&i)))&"</span></td>"
doc.WriteLine " <td><span id=""line"&i&""">"&MapXML(line)&"</span></td>"
doc.WriteLine " <td nowrap><a href=""vbscript:addline("&i&")"">Add</a> <a href=""vbscript:editline("&i&")"">Edit</a> <a href=""vbscript:deleteline("&i&")"">Del</a></td>"
doc.WriteLine " </tr>"
Next
Else
doc.WriteLine " <tr id=""row1"""&Style()&">"
doc.WriteLine " <th colspan=""4"">There are no lyrics available for this song.</th>"
doc.WriteLine " </tr>"
If Not (EvilLyrics = "") Then
doc.WriteLine " <tr id=""row2"""&Style()&">"
doc.WriteLine " <td colspan=""4""><p align=""center"">Rechecking EvilLyrics in <span id=""secs"">"&RecheckSecs&"</span> seconds.</p></td>"
doc.WriteLine " </tr>"
End If
End If
doc.WriteLine " </table>"
doc.WriteLine " </body>"
doc.WriteLine "</html>"
Call doc.Close
Call wb.Navigate(loc)
End Sub
Sub BackClick (ClickedBtn)
Dim res : res = SDB.MessageBox("Are you sure you wish to undo your changes?",mtConfirmation,Array(mbOk,MbCancel))
If res = 1 Then
Dim vars : Set vars = SDB.Objects("LyricVars")
vars.Item("isong") = -1
Set SDB.Objects("LyricVars") = vars
End If
End Sub
Sub SaveClick (ClickedBtn)
Dim res : res = SDB.MessageBox("Are you sure you wish to save your changes?",mtConfirmation,Array(mbOk,mbCancel))
If res = 1 Then
Dim Data : Set Data = SDB.Objects("LyricData")
Dim str : str = ""
Dim pos : pos = 1
If Data.Item("title") <> "" Then
str = str&"[ti:"&Data.Item("title")&"]"&VbCrLf
End If
If Data.Item("artist") <> "" Then
str = str&"[ar:"&Data.Item("artist")&"]"&VbCrLf
End If
If Data.Item("author") <> "" Then
str = str&"[au:"&Data.Item("author")&"]"&VbCrLf
End If
If Data.Item("album") <> "" Then
str = str&"[al:"&Data.Item("album")&"]"&VbCrLf
End If
If Data.Item("version") <> "" Then
str = str&"[ve:"&Data.Item("version")&"]"&VbCrLf
End If
Do While Not (Data.Item("time"&pos) = "")
Dim lng : lng = Clng(Data.Item("time"&pos))
If Right(str,2) <> VbCrLf Then
str = str&VbCrLf
End If
str = str&settime(lng)
str = str&Data.Item("line"&pos)
pos = pos+1
Loop
Dim song : Set song = SDB.Player.CurrentSong
song.Lyrics = str
Call song.UpdateDB
End If
End Sub
Sub LoopClick (ClickedBtn)
If ClickedBtn.Caption = "Loop: Yes" Then
ClickedBtn.Caption = "Loop: No"
Else
ClickedBtn.Caption = "Loop: Yes"
End If
End Sub
Sub out(txt)
Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
Dim logf : Set logf = fso.OpenTextFile(SDB.TemporaryFolder&"LyricTimer.log",8,True)
Call logf.WriteLine(txt)
Call logf.Close
End Sub
Sub OnInstall
Dim inip : inip = SDB.ScriptsPath&"Scripts.ini"
Dim inif : Set inif = SDB.Tools.IniFileByPath(inip)
If Not (inif Is Nothing) Then
inif.StringValue("LyricTimer","Filename") = "LyricTimer.vbs"
inif.StringValue("LyricTimer","Procname") = "LyricTimer"
inif.StringValue("LyricTimer","Order") = "17"
inif.StringValue("LyricTimer","DisplayName") = "Lyric Timer"
inif.StringValue("LyricTimer","Description") = "Add timings to lyrics"
inif.StringValue("LyricTimer","Language") = "VBScript"
inif.StringValue("LyricTimer","ScriptType") = "0"
SDB.RefreshScriptItems
End If
End Sub