Simple Lyrics Viewer

Download and get help for different MediaMonkey for Windows 4 Addons.

Moderators: Peke, Gurus

Begges

Simple Lyrics Viewer

Post by Begges »

Hi Monkey out there,

when i have added all lyrics from Evillyrics with my Eviltagger-script, i was searching for a script, that shows these lyrics from the ID3v2 tag
the info panel was a bit too much for me, as i can see album art and song infos straight in MM.
I was just missing a lyrics panel, as the one with the covers.

And here it is :-)
Please check and submit errors

Code: Select all


' a simple Show lyrics script
'just adds a docking panle with lyrics inside
'
'thanks to all forum members for their code snippets!!!!
'
'
'here are the ini-Lines
'
' [ShowLyrics]
' FileName=ShowLyrics.vbs
' ProcName=ShowLyrics
' Order=17
' DisplayName=Show  InsideLyrics (id3V2)
' Description=Shows InsideLyrics (id3V2)
' Language=VBScript
' ScriptType=0
'

Dim Tmr, strOldsong
Dim strPath
Dim lyrPanel

Sub Showlyrics
	ExportLyrics
	CreatePanel
	Set Tmr = SDB.CreateTimer(1000)
	Script.RegisterEvent Tmr, "OnTimer", "Update"
End Sub

Sub ExportLyrics
	Dim Song, strLyrics, strHeader
	Dim TmpFile
  	
	'exports the lyrics to a temporary html file
	strPath=sdb.applicationpath
	strPath=strPath & "~~SimpleLyricsTemp.html"
	Set Song = SDB.Player.CurrentSong
	strLyrics = Song.lyrics
	if StrLyrics = "" then StrLyrics ="No id3V2 Lyric Tag found in" & CHR(10) & Song.path
	strOldsong = song.path
	strheader = "<plaintext style=""font-family:Arial,sans-serif; font-size:10px;"">"
	strlyrics = strheader & strlyrics '& "</plaintext>"
	Set tmpFile = sdb.tools.filesystem.CreateTextFile (strPath, true)
	tmpFile.WriteLine strLyrics
End Sub


Sub CreatePanel
	Dim Form
	
	'creates the panel
	Set Form = SDB.Objects("LyricPanel")
	If Form is Nothing Then
		Set Form = SDB.UI.NewDockablePersistentPanel("LyricPanel")
		Form.DockedTo = 2
		Form.Common.Width = 250
		Form.Caption = "Lyrics"
		Set lyrPanel = SDB.UI.NewActiveX(Form, "Shell.Explorer")
		lyrPanel.Common.Align = 5  
		lyrPanel.Interf.Navigate strpath  ' open the temp-lyric-file
		Form.Common.Visible = True
		SDB.Objects("LyricPanel") = Form    
		SDB.Objects("LyricX") = lyrPanel.Interf
		Script.RegisterEvent Form, "OnClose", "FormClose"
	End If
End Sub

Sub Update(Timer)
	Dim NewSong
	Set NewSong = SDB.Player.CurrentSong
	If strOldsong <> NewSong.path Then
		ExportLyrics	'export new lyrics
		lyrPanel.Interf.Navigate strpath 'open the temp-lyric-file again
	End If

End Sub

Sub FormClose(Node)
	SDB.Objects("LyricPanel") = Nothing
	SDB.Objects("LyricX").Navigate "about:blank"
	SDB.Objects("LyricX") = Nothing
	Script.UnregisterEvents Tmr
End Sub
pah68
Posts: 1504
Joined: Wed Apr 07, 2004 5:26 pm
Location: Sydney, Australia

Post by pah68 »

Nice :wink: Thanks.

Love the new dockable window functionality 8)
Image
Image
Sammy20
Posts: 110
Joined: Thu Feb 17, 2005 5:42 am

Post by Sammy20 »

Is there a way to set the default size and position of the window.

I want to make it a floating window with a size of 600x800.

A toolbar button to activate this script would be really nice as well.
Begges

Post by Begges »

i like the dockable panel more and i also will not implement a toolbar, as i don't know how and the sricpt is only 3 clicks behind Tools --> Scripts --> Show Lyrics.

But i think that would be very easy, you will find the code here in the forum (as i found my code snippets also).
Begges

Lyricspanel with Autoscript and Menu

Post by Begges »

Ok, i recognised that in partymode it is difficult to see the panel :-(

so here is the same panel with Menu (View --> LyricsPanel)
Put this script into the AUTO-folder, no ini-changes necessary

Code: Select all


' a simple Show lyrics script
' just adds a docking panel with lyrics inside
'thanks to all forum members for their code snippets!!!!
'
'put this script into the Auto-Folder
'no ini-settings necessary

Option Explicit

Dim Tmr, strOldsong
Dim strPath
Dim lyrPanel
DIM Mnu, Form

'Autoexec 
Sub OnStartup
	'Call Showlyrics
	Showlyrics
	'Add the Lyricspanel to the View-Menu
	Set Mnu = SDB.UI.AddMenuItem(SDB.UI.Menu_View,1,-1)
	Mnu.Caption = "LyricsPanel"
	Mnu.shortcut = "Ctrl+Alt+y"
	Mnu.Checked = Form.Common.Visible
	Script.RegisterEvent Mnu, "OnClick", "ShowPanel"
End Sub 

Sub ShowPanel(Item)
  Form.Common.Visible = not Form.Common.Visible
  Mnu.Checked = Form.Common.Visible
End Sub 

Sub Showlyrics
	'Lyricsexport to temporary file
	ExportLyrics
	'Panel
	CreatePanel
	'Check with timer If new song is played
	Set Tmr = SDB.CreateTimer(1000)
	Script.RegisterEvent Tmr, "OnTimer", "Update"
End Sub

Sub ExportLyrics
	Dim Song, strLyrics, strHeader
	Dim TmpFile
  	
	'exports the lyrics to a temporary html file
	strPath=sdb.applicationpath
	strPath=strPath & "~~SimpleLyricsTemp.html"
	Set Song = SDB.Player.CurrentSong
	If song is Nothing Then
		strlyrics = "start player to view Lyrics"
	Else	
		strLyrics = Song.lyrics
	End If	
	If StrLyrics = "" Then StrLyrics ="No id3V2 Lyric Tag found in" & CHR(10) & Song.path
	
	If song is Nothing Then
		strOldsong ="no song"
	Else
		strOldsong = song.path
	End If
	strheader = "<table><tr><td><plaintext style=""font-family:Arial,sans-serIf; font-size:10px;"">"
	strlyrics = strheader & strlyrics '&"</table></tr></td></plaintext>"
	Set tmpFile = sdb.tools.filesystem.CreateTextFile (strPath, true)
	tmpFile.WriteLine strLyrics
End Sub


Sub CreatePanel
	'creates the panel
	Set Form = SDB.Objects("LyricPanel")
	If Form is Nothing Then
		Set Form = SDB.UI.NewDockablePersistentPanel("LyricPanel")
		Form.DockedTo = 4
		Form.Common.Width = 250
		Form.Caption = "Lyrics"
		Set lyrPanel = SDB.UI.NewActiveX(Form, "Shell.Explorer")
		lyrPanel.Common.Align = 5  
		lyrPanel.Interf.Navigate strpath  ' open the temp-lyric-file
		Form.Common.Visible = True
		SDB.Objects("LyricPanel") = Form    
		SDB.Objects("LyricX") = lyrPanel.Interf
		Script.RegisterEvent Form, "OnClose", "FormClose"
	End If
End Sub

Sub Update(Timer)
	Dim NewSong
	Set NewSong = SDB.Player.CurrentSong
	If Not NewSong is Nothing Then
		If strOldsong <> NewSong.path Then
			ExportLyrics	'export new lyrics
			lyrPanel.Interf.Navigate strpath 'open the temp-lyric-file again
		End If
	End If
End Sub

Sub FormClose(Node)
	'SDB.Objects("LyricPanel") = Nothing
	'SDB.Objects("LyricX").Navigate "about:blank"
	'SDB.Objects("LyricX") = Nothing
	'Script.UnregisterEvents Tmr
	Mnu.Checked = Form.Common.Visible
End Sub

Teknojnky
Posts: 5537
Joined: Tue Sep 06, 2005 11:01 pm
Contact:

Post by Teknojnky »

Very nice, works great with embedded lyrics that MM can read.

The dockable panels functionality is nice, hope more scripts start making use of it.
Sammy20
Posts: 110
Joined: Thu Feb 17, 2005 5:42 am

Post by Sammy20 »

Ok........cant you make it so it remembers the previous window posistion of the lyrics panel after closing Mediamonkey? And if you have the lyrics panel closed, and start up MM it remembers you had it closed previous session.

One other thing, is it possible to remove the 'lyrics' text from the dockable panel?
DiddeLeeDoo
Posts: 1017
Joined: Wed Mar 01, 2006 1:09 am
Location: In a jungle down under
Contact:

Post by DiddeLeeDoo »

First Impression WOW!!! That is fantastic.. Think you've just sold me on lyrics. I love it super-simple, and logical... Currently reading the scripting help file to see if window position and that sort of stuff can be remembered too.. The registry and the MediaMonkey.ini file can be used to remember stuff.. just learned that this week!.... :roll:
Image
DiddeLeeDoo
Posts: 1017
Joined: Wed Mar 01, 2006 1:09 am
Location: In a jungle down under
Contact:

Post by DiddeLeeDoo »

Sammy20 wrote: is it possible to remove the 'lyrics' text from the dockable panel?
I tried here and by changing

Form.Caption = "Lyrics"
to
Form.Caption = ""

you get a blank line instead of the text Lyrics.

Begges is super-fast, but just for the fun of it I'll have a go with window positions... this is good fun!!

ADDED:
Found that by going to the line

Form.DockedTo = 4

you can choose between
1 Left
2 Right
3 Top
4 Bottom
according to the help file.
Image
DiddeLeeDoo
Posts: 1017
Joined: Wed Mar 01, 2006 1:09 am
Location: In a jungle down under
Contact:

Post by DiddeLeeDoo »

Idea Drop:

SongLenght = 100%
Number of Lyrics Lines = 100%

Then do a little window.scroll Java to make it automatically scroll as the song plays...

Using percent, a short song with a lot of lyrics would get a fairly fast scroll, and a long song with little lyrics would get a slow scroll.
Image
Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

Post by Steegy »

Did you already try Trixmoto's scripts?

His scripts can edit and show scrolling lyrics.
Maybe you can work together or so?

(as far as I know, his scripts support lyrics in the tags, and your script supports lyrics in an external file)

Cheers
Steegy
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
DiddeLeeDoo
Posts: 1017
Joined: Wed Mar 01, 2006 1:09 am
Location: In a jungle down under
Contact:

Post by DiddeLeeDoo »

Steegy wrote:Did you already try Trixmoto's scripts?

His scripts can edit and show scrolling lyrics.
No, I haven't tried other lyrics scripts yet... Been to busy trying to figure out the simplest things with scripting... but doing one step at the time...

Think that's why I love these drops from Begges, they are simple and feature interesting ways to solve problems

I believe we all are co-operating here really. Things cannot be more open-source they are here, and I think that is wonderful.

I've learned a lot from reading this forum, and I hope now to be able to do some contributions myself... just have to get over the hill first...
Last edited by DiddeLeeDoo on Sat Apr 29, 2006 5:58 am, edited 1 time in total.
Image
Begges
Posts: 20
Joined: Fri Apr 28, 2006 3:52 pm
Location: Germany

Update: use ini to store visibilty

Post by Begges »

another draft now

fixes:
no lyrics was shown on startup, even if the song in the player has one
unregister Timer event when not shown

new features:
DockingPosition and visibility are stored in ini-File now

I like this forum also a lot :-)

Maybe you don't believe it but last weekend i even don't know Mediamonkey.
I have some experiences with VBA and together with this forum i was able to programm my three little srcipts (VUPlayer, Evilttager, Lyricspanel).
And i also had a lot of time last week, because i was ill ;-)

Scrolling with the song would be nice, but i have totally no knowledge of java/javascript and and i will not be ill next week (i hope). So maybe someone else could programm this. As you can see, i only use the <plaintext> in the html file, that was the simplest way. And i love the simple way :-)


Code removed

Code: Select all

code removed
updated on  later post
Last edited by Begges on Sat Apr 29, 2006 6:28 am, edited 2 times in total.
DiddeLeeDoo
Posts: 1017
Joined: Wed Mar 01, 2006 1:09 am
Location: In a jungle down under
Contact:

Post by DiddeLeeDoo »

I knew that's gonna happen... sitting here stuffing away with a few lines lines, and you have the whole thing finished!!

I do not know either... this java thing, but it seems to be just a few lines of code to add... Say if I use about 4 hours per line, I may get it done in just a few days....(Do not think anyone could afford to hire me as a scripter... :lol: )

I have this scripting help file open all the time these days.
http://www.mediamonkey.com/sw/webhelp/M ... ipting.chm
Last edited by DiddeLeeDoo on Sat Apr 29, 2006 7:04 am, edited 4 times in total.
Image
Begges
Posts: 20
Joined: Fri Apr 28, 2006 3:52 pm
Location: Germany

new code above

Post by Begges »

you find the new code above

one question:
is it necessary to unregister the other events, too (not only the timer)? Maybe because of performance issues?
Post Reply