New version (2.1) has been fixed so it should it should be much more stable when reading the lyrics. Also it switches off if you are running LyricTimer as this causes conflicts.
InlineLyrics.vbs
Code: Select all
'
' MediaMonkey Script
'
' NAME: InlineLyrics 2.1
'
' AUTHOR: trixmoto (http://trixmoto.net)
' DATE : 15/03/2006
'
' INSTALL: Copy to Scripts directory and add the following to Scripts.ini
' Don't forget to remove comments (') and set the order appropriately
' Needs file 'InlineLyrics2.vbs' to be in '{MM}\Scripts\'
'
' FIXES: Don't run if LyricTimer is running
' Improve reading of timestamps
'
' [InlineLyrics]
' FileName=InlineLyrics.vbs
' ProcName=InlineLyrics
' Order=12
' DisplayName=&InlineLyrics
' Description=Show timed lyrics in a progress bar
' Language=VBScript
' ScriptType=2
'
Option Explicit
Sub InlineLyrics
'check for LyricTimer running
Dim form,res
Set form = SDB.Objects("LyricTimer")
If Not (form is Nothing) Then
If form.Common.Visible Then Exit Sub
End If
'check helper script exists
Dim LoopScript,filesys
LoopScript = SDB.ApplicationPath&"Scripts\InlineLyrics2.vbs"
Set filesys = CreateObject("Scripting.FileSystemObject")
If not filesys.FileExists(LoopScript) Then
res = SDB.MessageBox("File '"&LoopScript&"' cannot be found.", mtError, Array(mbOk))
Exit Sub
End If
'run helper script
Dim lrc,WShell,command
lrc = SDB.Player.CurrentSong.Lyrics
If Left(lrc,1) = "[" Then
Set WShell = CreateObject("WScript.Shell")
command = "wscript "&Chr(34)&LoopScript&Chr(34)
res = WShell.Run(command, 1, 0)
End If
End Sub
InlineLyrics2.vbs
Code: Select all
'
' MediaMonkey Script
'
' NAME: InlineLyrics 2.1
'
' AUTHOR: trixmoto (http://trixmoto.net)
' DATE : 15/03/2006
'
' INSTALL: Helper script for 'InlineLyrics.vbs'
' Needs to be in '{MM}\Scripts\'
'
Option Explicit
Dim SDB,line
Set SDB = CreateObject("SongsDB.SDBApplication")
Set line = SDB.Progress
line.Text = "InLineLyrics by Trixmoto (http://trixmoto.net)"
Dim idx,tot,lrc
idx = SDB.Player.CurrentSong.ID
tot = SDB.Player.CurrentSong.SongLength
lrc = SDB.Player.CurrentSong.Lyrics
If lrc = "" Then
line.Text = "InlineLyrics - Error01 - No lyrics"
Else
lrc = deheader(lrc)
If lrc = "" Then
line.Text = "InlineLyrics - Error02 - No timestamps"
Else
lrc = simplify(lrc)
If lrc = "" Then
line.Text = "InlineLyrics - Error03 - No lines"
Else
Dim arr,lst,pos,tsp
arr = split(lrc,VBCrLf)
lst = SDB.Player.CurrentSongLength
Do While valid()
If SDB.Player.PlaybackTime < lst Then
pos = 0
tsp = gettime(arr(pos))
End If
If pos <= UBound(arr) Then
If tsp < SDB.Player.PlaybackTime+100 Then
line.Text = getline(arr(pos))
pos = pos + 1
If pos <= UBound(arr) Then tsp = gettime(arr(pos))
End If
End If
lst = SDB.Player.PlaybackTime
WScript.Sleep 100
Loop
End If
End If
End If
Set line = nothing
Set SDB = nothing
Function valid()
valid = true
If line.Terminate Then 'user cancels
valid = false
Exit Function
End If
If not SDB.Player.CurrentSong.ID = idx Then 'song changes
valid = false
Exit Function
End If
If not SDB.Player.isPlaying Then 'play stopped
valid = false
Exit Function
End If
If SDB.Player.PlaybackTime+100 > tot Then 'song ended
valid = false
Exit Function
End If
Dim form,res 'LyricTimer running
Set form = SDB.Objects("LyricTimer")
If Not (form is Nothing) Then
If form.Common.Visible Then
valid = false
Exit Function
End If
End If
End Function
Function deheader(txt)
Dim wid,pos
wid = Len(txt)
pos = 0
Do while pos < wid
pos = pos + 1
If Mid(txt,pos,2) = "[0" Then Exit Do
Loop
deheader = mid(txt,pos)
End Function
Function simplify(txt)
Dim a,b,d,c,l
a = InStr(txt,"<")
If a = 0 Then
simplify = txt
Exit Function
End If
b = InStr(txt,">")
l = Len(txt)
c = Mid(txt,1,a-1)
If b = 0 Then b = a
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 gettime(txt)
Dim min,sec,mil,temp
If Left(txt,1) = "[" Then
temp = Mid(txt,2,2)
If isNumeric(temp) Then min = Clng(temp)
temp = Mid(txt,5,2)
If isNumeric(temp) Then sec = Clng(temp)
temp = Mid(txt,8,2)
If isNumeric(temp) Then mil = Clng(temp)
End If
gettime = min*60000 + sec*1000 + mil*1
End Function
Function getline(txt)
Dim length
length = Len(txt)-10
getline = mid(txt,11,length)
End Function