Simple Lyrics Viewer

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

Sammy20
Posts: 110
Joined: Thu Feb 17, 2005 5:42 am

Post by Sammy20 » Sat Apr 29, 2006 6:24 am

Where is the new draft?

Begges
Posts: 20
Joined: Fri Apr 28, 2006 3:52 pm
Location: Germany

Timed Lyrics

Post by Begges » Sat Apr 29, 2006 6:25 am

i will not need my Lyricspanel scrolling with songlength (and maybe they only sing at the end of the song ;-)) because:

- for the lyrics i use Evillyrics and i can also implement timed lyrics there
- with my Eviltagger-script i can import these lyrics to the id3v2-Tag
- and with the Lyricspanel i can show them from the tag

so, if i like to make a karaoke-thing i will use the Evillyrics karoke function and not my lyricspanel.

for timestamped lyrices use the InlineLyrics script form this forum.

Begges
Posts: 20
Joined: Fri Apr 28, 2006 3:52 pm
Location: Germany

here it is

Post by Begges » Sat Apr 29, 2006 6:26 am

Here is the new draft:

Code: Select all


' a simple Show lyrics script by BEGGES
' 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 LyricsPanelMNU, LyricsPanelForm

'Autoexec 
Sub OnStartup
	'######################################
	'Set the Path o the temporary HTML-File
	strPath=sdb.applicationpath
	strPath=strPath & "~~SimpleLyricsTemp.html"
	'######################################
	
	'CreatePanel to show Lyrics
	CreatePanel
	
	'Add the Lyricspanel to the View-Menu
	Set LyricsPanelMNU = SDB.UI.AddMenuItem(SDB.UI.Menu_View,1,-1)
	LyricsPanelMNU.Caption = "LyricsPanel"
	LyricsPanelMNU.shortcut = "Ctrl+Alt+Y"
	
	'Check the laststatus of the Lyricspanel
	CheckIni
	
	LyricsPanelMNU.Checked = LyricsPanelForm.Common.Visible
	
	'Register events
	'
	'TIMER:
	'Check with timer If new song is played
	LyricsTimer
	'MENU:
	Script.RegisterEvent LyricsPanelMNU, "OnClick", "ShowPanel"
	'SHUTDOWN
	Script.RegisterEvent SDB, "OnShutdown", "SDBShutdown"
End Sub 

Sub LyricsTimer
	Set Tmr = SDB.CreateTimer(1000)
	Script.RegisterEvent Tmr, "OnTimer", "SongUpdate"
End Sub

Sub CreatePanel
	'Creates the panel
	'But makes it not visible --> this is done after checking the ini-File
	Set LyricsPanelForm = SDB.Objects("LyricPanel")
	If LyricsPanelForm is Nothing Then
		Set LyricsPanelForm = SDB.UI.NewDockablePersistentPanel("LyricPanel")
		LyricsPanelForm.Common.Width = 250
		LyricsPanelForm.Caption = "Lyrics"
		Set lyrPanel = SDB.UI.NewActiveX(LyricsPanelForm, "Shell.Explorer")
		lyrPanel.Common.Align = 5  
		lyrPanel.Interf.Navigate strpath  ' open the temp-lyric-file
		SDB.Objects("LyricPanel") = LyricsPanelForm    
		SDB.Objects("LyricX") = lyrPanel.Interf
		Script.RegisterEvent LyricsPanelForm, "OnClose", "FormClose"
	End If
End Sub

Sub CheckIni
	If sdb.inifile.stringvalue("LyricsPanel","DockedTo") <> "" then
		LyricsPanelForm.Dockedto = sdb.inifile.stringvalue("LyricsPanel","DockedTo")
	Else
		LyricsPanelForm.Dockedto = 4
	End If
	If sdb.inifile.stringvalue("LyricsPanel","Show")="True" then
		LyricsPanelForm.Common.Visible = True
	Else
		LyricsPanelForm.Common.Visible = False
	End if
End Sub


Sub ExportLyrics
	Dim Song, strLyrics, strHeader
	Dim TmpFile
  	
	'exports the lyrics to the temporary html file
	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
	End If	
	
	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 SDBShutDown
	sdb.inifile.stringvalue("LyricsPanel","Show")=LyricsPanelForm.Common.Visible
	sdb.inifile.stringvalue("LyricsPanel","DockedTo")=LyricsPanelForm.DockedTo
End Sub

Sub ShowPanel(Item)
	LyricsPanelForm.Common.Visible = not LyricsPanelForm.Common.Visible
	LyricsPanelMNU.Checked = LyricsPanelForm.Common.Visible
	If LyricsPanelForm.Common.Visible = True then
		LyricsTimer
	Else
		Set Tmr = Nothing
		Script.UnRegisterEvents Tmr
	End If
End Sub 

Sub SongUpdate(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)
	LyricsPanelMNU.Checked = LyricsPanelForm.Common.Visible
	Set Tmr = Nothing
	Script.UnRegisterEvents Tmr
End Sub



DiddeLeeDoo
Posts: 1017
Joined: Wed Mar 01, 2006 1:09 am
Location: In a jungle down under
Contact:

Post by DiddeLeeDoo » Sat Apr 29, 2006 7:40 am

Fantastic contribution!!

It's like it's a part of MM that's always been there! I'm overwhelmed..

Some scripts can be pages long, but this is like a 'Tutorial Example'
Thank you!
Image

Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm
Location: Belgium
Contact:

Post by Steegy » Mon May 01, 2006 7:28 am

one question:
is it necessary to unregister the other events, too (not only the timer)? Maybe because of performance issues?
Events have to be unregistered, objects have to be set to Nothing, when you don't need them anymore.
It's a performance thing and a good-programming thing (even if MM would automaticly unregisters events; probably not).

Notice to all programmers:

Code: Select all

Sub Blabla

  Dim MyObject
  Set MyObject = SDB

  '...

  Set MyObject = Nothing

End Sub
The last line in the sub (Set MyObject = Nothing) is unnecessary, because the object reference is automaticly released when the program is out of the scope (sub), so when the sub finishes.

But this *is* necessary:
(if CloseDown is called e.g. if you close a custom made panel (while MediaMonkey continues to run))

Code: Select all

Sub CloseDown

  Set SDB.Objects("MyObject") = Nothing

End Sub
Because this object reference doesn't get released automaticly (it still exists in MM, even if you would end the sub without setting the object reference to Nothing).
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 » Mon May 01, 2006 7:49 am

Thank you!
Image

keiju

Post by keiju » Wed May 03, 2006 12:40 pm

i must say: lovely thing u give us :)

THANK YOU i love this script

Begges
Posts: 20
Joined: Fri Apr 28, 2006 3:52 pm
Location: Germany

Post by Begges » Wed May 03, 2006 3:26 pm

Your welcome :-)

this forum is very motivating, maybe i will find another idea about somethings missing in MM ;-)

Gervasio Antonio
Posts: 14
Joined: Tue Jul 19, 2005 2:36 pm

A little mod...

Post by Gervasio Antonio » Wed May 10, 2006 1:37 pm

Hello, Begges
Thanks for this wonderful script. It's simply amazing!

The only thing I really disliked on it was the appearence of the lyrics page (Letters were too small, layout too simple...).
So I made a little mod of your script, with following changes:

- Stylesheets support: lyrics_panel.css file was added. It can be edited to change the appearence of lyrics page. My layout includes a nice background image;
- Song Title and Artist Name are displayed before lyrics;
- All localizable strings are declared in the beginnig of the script. This way, it is much more friendly for translation.

See the screenshot and tell me what you think

Image

Begges
Posts: 20
Joined: Fri Apr 28, 2006 3:52 pm
Location: Germany

Post by Begges » Wed May 10, 2006 3:18 pm

Looks great! Maybe you can post your code here.....

Gervasio Antonio
Posts: 14
Joined: Tue Jul 19, 2005 2:36 pm

Lyrics Panel Mod

Post by Gervasio Antonio » Wed May 10, 2006 3:59 pm

OK! Here we go!

Instructions:
1 - Save "lyrics_panel.css" and "lyrics_panel_bg.gif" files to %MediaMonkeyDir%
2 - Save "lyrics_panel.vbs" file to %MediaMonkeyDir%\Scripts\Auto, replacing old lyrics script, in case it exists there.
3 - Restart MediaMonkey and enjoy it!


lyrics_panel_bg.gif:
Image

lyrics_panel.css:

Code: Select all

body{font:8pt 'Trebuchet MS', Arial, sans serif;margin:0;padding:17px 14px;background:#fff url('lyrics_panel_bg.gif') no-repeat}
plaintext{font:8pt 'Trebuchet MS', Arial, sans serif;margin:0;padding:5px}
h1{margin:5px;clear:both;font-size:150%;font-style:italic;color:#222}
h2{margin:5px;clear:both;font-size:130%;font-weight:normal;padding:0 0 12px 0}

lyrics_panel.vbs:

Code: Select all

' a simple Show lyrics script by BEGGES
' modded by gege
' 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 LyricsPanelMNU, LyricsPanelForm

Dim stringsMenuCaption
Dim stringsMenuShortcut
Dim stringsPanelCaption
Dim stringsMsgStartPlayer
Dim stringsMsgNoLyrics

'Autoexec
Sub OnStartup
   '######################################
   'Set the Path o the temporary HTML-File
   strPath=sdb.applicationpath
   strPath=strPath & "~~SimpleLyricsTemp.html"

   'Localizable strings
   stringsMenuCaption = "LyricsPanel"
   stringsMenuShortcut = "Ctrl+Alt+Y"
   stringsPanelCaption = "Lyrics"
   stringsMsgStartPlayer = "start player to view Lyrics"
   stringsMsgNoLyrics = "No id3V2 Lyric Tag found in"
   '######################################
   
   'CreatePanel to show Lyrics
   CreatePanel
   
   'Add the Lyricspanel to the View-Menu
   Set LyricsPanelMNU = SDB.UI.AddMenuItem(SDB.UI.Menu_View,1,-1)
   LyricsPanelMNU.Caption = stringsMenuCaption
   LyricsPanelMNU.shortcut = stringsMenuShortcut
   
   'Check the laststatus of the Lyricspanel
   CheckIni
   
   LyricsPanelMNU.Checked = LyricsPanelForm.Common.Visible
   
   'Register events
   '
   'TIMER:
   'Check with timer If new song is played
   LyricsTimer
   'MENU:
   Script.RegisterEvent LyricsPanelMNU, "OnClick", "ShowPanel"
   'SHUTDOWN
   Script.RegisterEvent SDB, "OnShutdown", "SDBShutdown"
End Sub

Sub LyricsTimer
   Set Tmr = SDB.CreateTimer(1000)
   Script.RegisterEvent Tmr, "OnTimer", "SongUpdate"
End Sub

Sub CreatePanel
   'Creates the panel
   'But makes it not visible --> this is done after checking the ini-File
   Set LyricsPanelForm = SDB.Objects("LyricPanel")
   If LyricsPanelForm is Nothing Then
      Set LyricsPanelForm = SDB.UI.NewDockablePersistentPanel("LyricPanel")
      LyricsPanelForm.Common.Width = 250
      LyricsPanelForm.Caption = stringsPanelCaption
      Set lyrPanel = SDB.UI.NewActiveX(LyricsPanelForm, "Shell.Explorer")
      lyrPanel.Common.Align = 5 
      lyrPanel.Interf.Navigate strpath  ' open the temp-lyric-file
      SDB.Objects("LyricPanel") = LyricsPanelForm   
      SDB.Objects("LyricX") = lyrPanel.Interf
      Script.RegisterEvent LyricsPanelForm, "OnClose", "FormClose"
   End If
End Sub

Sub CheckIni
   If sdb.inifile.stringvalue("LyricsPanel","DockedTo") <> "" then
      LyricsPanelForm.Dockedto = sdb.inifile.stringvalue("LyricsPanel","DockedTo")
   Else
      LyricsPanelForm.Dockedto = 4
   End If
   If sdb.inifile.stringvalue("LyricsPanel","Show")="True" then
      LyricsPanelForm.Common.Visible = True
   Else
      LyricsPanelForm.Common.Visible = False
   End If
End Sub


Sub ExportLyrics
   Dim Song, strLyrics, strCompleteLyrics, strHeaderBegin, strHeaderEnd, strSongTitle, strArtistName
   Dim strQueryArtist, strQueryMusic, strHttpPath
   Dim TmpFile
     
   'exports the lyrics to the temporary html file
   Set Song = SDB.Player.CurrentSong
   If Song is Nothing Then
      strLyrics = stringsMsgStartPlayer
   Else   
      strLyrics = Song.lyrics
   End If   
   If StrLyrics = "" Then
      StrLyrics = stringsMsgNoLyrics & CHR(10) & Song.path
   End If   
   
   If Song is Nothing Then
      strOldsong ="no song"
   Else
         strOldsong = song.path
   End If
   strHeaderBegin = "<html><head><link href=""lyrics_panel.css"" rel=""stylesheet"" type=""text/css""></head><body><div id=""bg"">"
   strSongTitle =  "<h1>" & song.Title & "</h1>"
   strArtistName = "<h2>" & song.ArtistName & "</h2>"
   strHeaderEnd = "<plaintext>"
   strCompleteLyrics = strHeaderBegin & strSongTitle & strArtistName & strHeaderEnd & strLyrics

   Set tmpFile = sdb.tools.filesystem.CreateTextFile (strPath, true)
   tmpFile.WriteLine strCompleteLyrics
End Sub

Sub SDBShutDown
   sdb.inifile.stringvalue("LyricsPanel","Show")=LyricsPanelForm.Common.Visible
   sdb.inifile.stringvalue("LyricsPanel","DockedTo")=LyricsPanelForm.DockedTo
End Sub

Sub ShowPanel(Item)
   LyricsPanelForm.Common.Visible = not LyricsPanelForm.Common.Visible
   LyricsPanelMNU.Checked = LyricsPanelForm.Common.Visible
   If LyricsPanelForm.Common.Visible = True then
      LyricsTimer
   Else
      Set Tmr = Nothing
      Script.UnRegisterEvents Tmr
   End If
End Sub

Sub SongUpdate(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)
   LyricsPanelMNU.Checked = LyricsPanelForm.Common.Visible
   Set Tmr = Nothing
   Script.UnRegisterEvents Tmr
End Sub
Last edited by Gervasio Antonio on Thu May 11, 2006 9:59 am, edited 2 times in total.

Gervasio Antonio
Posts: 14
Joined: Tue Jul 19, 2005 2:36 pm

New stylesheets???

Post by Gervasio Antonio » Wed May 10, 2006 4:05 pm

Maybe someone could create new stylesheets and backgrounds, to make the panel look even prettier...

Gervasio Antonio
Posts: 14
Joined: Tue Jul 19, 2005 2:36 pm

New "theme" for Lyrics Panel

Post by Gervasio Antonio » Thu May 11, 2006 9:54 am

I'm addicted to this plugin....

Here is another "theme" for Lyrics Panel. Let's call it "Blue Quotes".
It goes well with Blue Monkey skin.

Instructions, again:
1 - Save "lyrics_panel.css" and "lyrics_panel_bg.gif" files to %MediaMonkeyDir%
2 - Save "lyrics_panel.vbs" file (code two posts above) to %MediaMonkeyDir%\Scripts\Auto, replacing old lyrics script, in case it exists there.
3 - Restart MediaMonkey and enjoy it!

lyrics_panel.css:

Code: Select all

 
body{font:8pt Verdana, Arial, sans serif;margin:0;padding:17px 14px;background:#bed7f4 url('lyrics_panel_bg.gif') no-repeat}
plaintext{font:8pt Verdana, Arial, sans serif;margin:0;padding:15px 5px}
h1{margin:5px;clear:both;font-size:150%;font-style:italic;color:#222}
h2{margin:5px;clear:both;font-size:130%;font-weight:normal;padding:0 0 12px 0}
lyrics_panel_bg.gif
Image


Screenshot:
Image
Last edited by Gervasio Antonio on Thu May 11, 2006 10:03 am, edited 1 time in total.

DiddeLeeDoo
Posts: 1017
Joined: Wed Mar 01, 2006 1:09 am
Location: In a jungle down under
Contact:

Post by DiddeLeeDoo » Thu May 11, 2006 10:00 am

What a great team effort! I'm impressed. Makes it all so much more fun!
Image

rovingcowboy
Posts: 14153
Joined: Sat Oct 25, 2003 7:57 am
Location: (Texas)
Contact:

Post by rovingcowboy » Thu May 11, 2006 4:34 pm

I think it is good too, however it ain't great.

i found http://www.karafun.com and i aint changing from it.

there is nothing better for karaoke then karafun.

8)

but this as a lyrics viewer in monkey is good. :lol:
roving cowboy / keith hall. My skins http://www.mediamonkey.com/forum/viewto ... =9&t=16724 for some help check on Monkey's helpful messages at http://www.mediamonkey.com/forum/viewto ... 4008#44008 MY SYSTEMS.1.Jukebox WinXp pro sp 3 version 3.5 gigabyte mb. 281 GHz amd athlon x2 240 built by me.) 2.WinXP pro sp3, vers 2.5.5 and vers 3.5 backup storage, shuttle 32a mb,734 MHz amd athlon put together by me.) 3.Dell demension, winxp pro sp3, mm3.5 spare jukebox.) 4.WinXp pro sp3, vers 3.5, dad's computer bought from computer store. )5. Samsung Galaxy 5 Android 5) 6. Proscan tablet Android 4.3 ) 7. amd a8-5600 apu 3.60ghz mm version 4 windows 7 pro bought from computer store.

Post Reply