by fizzjob » Tue Oct 06, 2009 9:50 am
It works! Good gravy, it works!
If any of you are using Google Chrome, here are the bits you're gonna need:
Install the following MM script:
http://eriqjaffe.50webs.com/chromeoutput.mmip.
Then install the following Chrome extension:
http://eriqjaffe.50webs.com/testext.crx. Initially, the toolstrip won't have any song information until a new track is played. Once you play a new track, it'll start picking up on it.
I'm not 100% sure if Chrome generates the same folder name on different machines when you install an extension, so you may need to edit lines 39 and 40 of the .vbs script to reflect where Chrome installs the extension.
Here's the basics of how it works - MM writes the artist and name of the song to a text file (or a status message if it's stopped or closed). The Chrome extension just reads that text file and inserts it into an HTML file that gets displayed in the toolstrip at the bottom of the page:
Clicking on it will bring up the cover art of the currently playing track (or a big ol' question mark if the art can't be retrieved).
I left code in the .vbs script to pull more information about the current song that is being displayed. If you want to change what's displayed in the toolstrip, you can edit line 119 to your heart's content.
Also, please note that I am currently running the Development Branch of Google Chrome, your results with the stable/release version may vary.
Thanks to trixmoto for letting me recycle his "Now Playing FTP" script, which was used as the base (well, the vast majority) of the MM script.
And, in case you're wondering, here's the code:
Code: Select all
'' MediaMonkey Script
'
' NAME: Chrome Output 1.1
'
' AUTHOR: eriqjaffe, although 95% of this script is taken verbatim from "Now Playing FTP" by trixmoto (http://trixmoto.net)
' DATE : 21/12/2008
Option Explicit
Sub OnStartup
Call Script.RegisterEvent(SDB,"OnPlay","Event_OnPlay")
Call Script.RegisterEvent(SDB,"OnStop","Event_OnStop")
Call Script.RegisterEvent(SDB,"OnShutdown","Event_OnShutdown")
Call Script.RegisterEvent(SDB,"OnPause","Event_OnPause")
End Sub
Sub Event_OnPlay()
Call SendInfo(0)
End Sub
Sub Event_OnStop()
Call SendInfo(1)
End Sub
Sub Event_OnShutdown()
Call SendInfo(2)
End Sub
Sub Event_OnPause()
Call SendInfo(3)
End Sub
Sub SendInfo(mode)
Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
Dim wsh : Set wsh = CreateObject("WScript.Shell")
'Dim loc : loc = "c:\testext\mm_output.txt"
Dim loc : loc = wsh.ExpandEnvironmentStrings("%USERPROFILE%")&"\local settings\application data\Google\Chrome\User Data\Default\Extensions\npafjnbpbkpgdfkafnabghkdgmbhinhe\1.1\mm_output.txt"
Dim art : art = wsh.ExpandEnvironmentStrings("%USERPROFILE%")&"\local settings\application data\Google\Chrome\User Data\Default\Extensions\npafjnbpbkpgdfkafnabghkdgmbhinhe\1.1\cover.html"
Dim tmp : Set tmp = fso.CreateTextFile(loc,True)
If mode = 1 Then
Call tmp.WriteLine("<img src=""mm.png""> MediaMonkey is idle.")
tmp.Close
ElseIf mode = 2 Then
Call tmp.WriteLine("<img src=""mm.png""> MediaMonkey is not running.")
tmp.Close
Else
'get current song
Dim cur : Set cur = SDB.Player.CurrentSong
If cur Is Nothing Then
Exit Sub
End If
'get settings
Dim site : site = ""
Dim user : user = ""
Dim pass : pass = ""
Dim path : path = ""
Dim arti : arti = ""
Dim albu : albu = ""
Dim year : year = ""
Dim name : name = ""
Dim secs : secs = ""
Dim genr : genr = ""
Dim dnum : dnum = ""
Dim tnum : tnum = ""
Dim artw : artw = ""
Dim recs : recs = ""
Dim aart : aart = ""
Dim rati : rati = ""
Dim temp : temp = ""
Dim arr
Dim tmp2 : tmp2 = ""
'check songlength
Dim msec : msec = 0
If IsNumeric(secs) Then
msec = secs*1000
End If
If cur.SongLength < msec Then
Exit Sub
End If
'create file
If Not (cur Is Nothing) Then
name = cur.Title
arti = cur.ArtistName
albu = cur.AlbumName
year = cur.Year
genr = cur.Genre
dnum = cur.DiscNumberStr
tnum = cur.TrackOrderStr
aart = cur.AlbumArtistName
rati = cur.Rating
path = cur.Path
artw = GetAlbumArt(cur,0)
If HtmlEncode(Mid(artw,InStrRev(artw,"\")+1)) = "np.jpg" Then
temp = "embedded"
artw = wsh.ExpandEnvironmentStrings("%TEMP%")&"\np.jpg"
Else
arr = Split(HtmlEncode(path),"\")
temp = "linked"
dim y : y = Ubound(arr) - 1
dim x : for x = 0 to y
tmp2 = tmp2 + arr(x) + "\"
next
artw = tmp2&Mid(artw,InStrRev(artw,"\")+1)
End If
If fso.FileExists(artw) Then
fso.CopyFile artw,wsh.ExpandEnvironmentStrings("%USERPROFILE%")&"\local settings\application data\Google\Chrome\User Data\Default\Extensions\npafjnbpbkpgdfkafnabghkdgmbhinhe\1.1\cover.jpg"
Else
fso.CopyFile wsh.ExpandEnvironmentStrings("%USERPROFILE%")&"\local settings\application data\Google\Chrome\User Data\Default\Extensions\npafjnbpbkpgdfkafnabghkdgmbhinhe\1.1\nocover.jpg",wsh.ExpandEnvironmentStrings("%USERPROFILE%")&"\local settings\application data\Google\Chrome\User Data\Default\Extensions\npafjnbpbkpgdfkafnabghkdgmbhinhe\1.1\cover.jpg"
End If
End If
' If mode = 3 Then
' Call tmp.WriteLine(HtmlEncode(arti) & " - " & HtmlEncode(name) & " (Paused)")
' Else
Call tmp.WriteLine("<img src=""mm.png""> " & HtmlEncode(arti) & " - " & HtmlEncode(name))
'Call tmp.WriteLine(" $image = "&temp)
'Call tmp.WriteLine(artw)
' End If
tmp.Close
end if
End Sub
Function GetAlbumArt(track,num)
GetAlbumArt = Replace(Script.ScriptPath,"chromeoutput.vbs","default.jpg")
Dim fso : Set fso = SDB.Tools.FileSystem
Dim wsh : Set wsh = CreateObject("WScript.Shell")
Dim str : str = "\np.jpg"
If num > 0 Then
str = "\np"&num&".jpg"
End If
Dim temp : temp = wsh.ExpandEnvironmentStrings("%TEMP%")&str
Dim pics : Set pics = track.AlbumArt
If Not (pics Is Nothing) Then
Dim i : i = 0
For i = 0 To pics.Count-1
If (pics.Item(i).ItemStorage = 0) Or (num > 0) Then
Dim img : Set img = pics.Item(i).Image
If Not (img Is Nothing) Then
Dim outimg : Set outimg = fso.CreateTextFile(temp,True)
If Not (outimg Is Nothing) Then
Call outimg.WriteData(img.ImageData,img.ImageDataLen)
outimg.Close
GetAlbumArt = temp
Exit Function
End If
End If
Else
GetAlbumArt = pics.Item(i).PicturePath
Exit Function
End If
Next
End If
End Function
Function HtmlEncode(str)
HtmlEncode = SDB.toAscii(str)
HtmlEncode = Replace(HtmlEncode,"&","&")
HtmlEncode = Replace(HtmlEncode,"""",""")
HtmlEncode = Replace(HtmlEncode,"<","<")
HtmlEncode = Replace(HtmlEncode,">",">")
End Function
It works! Good gravy, it works!
If any of you are using Google Chrome, here are the bits you're gonna need:
Install the following MM script: http://eriqjaffe.50webs.com/chromeoutput.mmip.
Then install the following Chrome extension: http://eriqjaffe.50webs.com/testext.crx. Initially, the toolstrip won't have any song information until a new track is played. Once you play a new track, it'll start picking up on it.
I'm not 100% sure if Chrome generates the same folder name on different machines when you install an extension, so you may need to edit lines 39 and 40 of the .vbs script to reflect where Chrome installs the extension.
Here's the basics of how it works - MM writes the artist and name of the song to a text file (or a status message if it's stopped or closed). The Chrome extension just reads that text file and inserts it into an HTML file that gets displayed in the toolstrip at the bottom of the page:
[img]http://img200.imageshack.us/img200/4600/pastedimager.jpg[/img]
Clicking on it will bring up the cover art of the currently playing track (or a big ol' question mark if the art can't be retrieved).
I left code in the .vbs script to pull more information about the current song that is being displayed. If you want to change what's displayed in the toolstrip, you can edit line 119 to your heart's content.
Also, please note that I am currently running the Development Branch of Google Chrome, your results with the stable/release version may vary.
Thanks to trixmoto for letting me recycle his "Now Playing FTP" script, which was used as the base (well, the vast majority) of the MM script.
And, in case you're wondering, here's the code:
[code]'' MediaMonkey Script
'
' NAME: Chrome Output 1.1
'
' AUTHOR: eriqjaffe, although 95% of this script is taken verbatim from "Now Playing FTP" by trixmoto (http://trixmoto.net)
' DATE : 21/12/2008
Option Explicit
Sub OnStartup
Call Script.RegisterEvent(SDB,"OnPlay","Event_OnPlay")
Call Script.RegisterEvent(SDB,"OnStop","Event_OnStop")
Call Script.RegisterEvent(SDB,"OnShutdown","Event_OnShutdown")
Call Script.RegisterEvent(SDB,"OnPause","Event_OnPause")
End Sub
Sub Event_OnPlay()
Call SendInfo(0)
End Sub
Sub Event_OnStop()
Call SendInfo(1)
End Sub
Sub Event_OnShutdown()
Call SendInfo(2)
End Sub
Sub Event_OnPause()
Call SendInfo(3)
End Sub
Sub SendInfo(mode)
Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
Dim wsh : Set wsh = CreateObject("WScript.Shell")
'Dim loc : loc = "c:\testext\mm_output.txt"
Dim loc : loc = wsh.ExpandEnvironmentStrings("%USERPROFILE%")&"\local settings\application data\Google\Chrome\User Data\Default\Extensions\npafjnbpbkpgdfkafnabghkdgmbhinhe\1.1\mm_output.txt"
Dim art : art = wsh.ExpandEnvironmentStrings("%USERPROFILE%")&"\local settings\application data\Google\Chrome\User Data\Default\Extensions\npafjnbpbkpgdfkafnabghkdgmbhinhe\1.1\cover.html"
Dim tmp : Set tmp = fso.CreateTextFile(loc,True)
If mode = 1 Then
Call tmp.WriteLine("<img src=""mm.png""> MediaMonkey is idle.")
tmp.Close
ElseIf mode = 2 Then
Call tmp.WriteLine("<img src=""mm.png""> MediaMonkey is not running.")
tmp.Close
Else
'get current song
Dim cur : Set cur = SDB.Player.CurrentSong
If cur Is Nothing Then
Exit Sub
End If
'get settings
Dim site : site = ""
Dim user : user = ""
Dim pass : pass = ""
Dim path : path = ""
Dim arti : arti = ""
Dim albu : albu = ""
Dim year : year = ""
Dim name : name = ""
Dim secs : secs = ""
Dim genr : genr = ""
Dim dnum : dnum = ""
Dim tnum : tnum = ""
Dim artw : artw = ""
Dim recs : recs = ""
Dim aart : aart = ""
Dim rati : rati = ""
Dim temp : temp = ""
Dim arr
Dim tmp2 : tmp2 = ""
'check songlength
Dim msec : msec = 0
If IsNumeric(secs) Then
msec = secs*1000
End If
If cur.SongLength < msec Then
Exit Sub
End If
'create file
If Not (cur Is Nothing) Then
name = cur.Title
arti = cur.ArtistName
albu = cur.AlbumName
year = cur.Year
genr = cur.Genre
dnum = cur.DiscNumberStr
tnum = cur.TrackOrderStr
aart = cur.AlbumArtistName
rati = cur.Rating
path = cur.Path
artw = GetAlbumArt(cur,0)
If HtmlEncode(Mid(artw,InStrRev(artw,"\")+1)) = "np.jpg" Then
temp = "embedded"
artw = wsh.ExpandEnvironmentStrings("%TEMP%")&"\np.jpg"
Else
arr = Split(HtmlEncode(path),"\")
temp = "linked"
dim y : y = Ubound(arr) - 1
dim x : for x = 0 to y
tmp2 = tmp2 + arr(x) + "\"
next
artw = tmp2&Mid(artw,InStrRev(artw,"\")+1)
End If
If fso.FileExists(artw) Then
fso.CopyFile artw,wsh.ExpandEnvironmentStrings("%USERPROFILE%")&"\local settings\application data\Google\Chrome\User Data\Default\Extensions\npafjnbpbkpgdfkafnabghkdgmbhinhe\1.1\cover.jpg"
Else
fso.CopyFile wsh.ExpandEnvironmentStrings("%USERPROFILE%")&"\local settings\application data\Google\Chrome\User Data\Default\Extensions\npafjnbpbkpgdfkafnabghkdgmbhinhe\1.1\nocover.jpg",wsh.ExpandEnvironmentStrings("%USERPROFILE%")&"\local settings\application data\Google\Chrome\User Data\Default\Extensions\npafjnbpbkpgdfkafnabghkdgmbhinhe\1.1\cover.jpg"
End If
End If
' If mode = 3 Then
' Call tmp.WriteLine(HtmlEncode(arti) & " - " & HtmlEncode(name) & " (Paused)")
' Else
Call tmp.WriteLine("<img src=""mm.png""> " & HtmlEncode(arti) & " - " & HtmlEncode(name))
'Call tmp.WriteLine(" $image = "&temp)
'Call tmp.WriteLine(artw)
' End If
tmp.Close
end if
End Sub
Function GetAlbumArt(track,num)
GetAlbumArt = Replace(Script.ScriptPath,"chromeoutput.vbs","default.jpg")
Dim fso : Set fso = SDB.Tools.FileSystem
Dim wsh : Set wsh = CreateObject("WScript.Shell")
Dim str : str = "\np.jpg"
If num > 0 Then
str = "\np"&num&".jpg"
End If
Dim temp : temp = wsh.ExpandEnvironmentStrings("%TEMP%")&str
Dim pics : Set pics = track.AlbumArt
If Not (pics Is Nothing) Then
Dim i : i = 0
For i = 0 To pics.Count-1
If (pics.Item(i).ItemStorage = 0) Or (num > 0) Then
Dim img : Set img = pics.Item(i).Image
If Not (img Is Nothing) Then
Dim outimg : Set outimg = fso.CreateTextFile(temp,True)
If Not (outimg Is Nothing) Then
Call outimg.WriteData(img.ImageData,img.ImageDataLen)
outimg.Close
GetAlbumArt = temp
Exit Function
End If
End If
Else
GetAlbumArt = pics.Item(i).PicturePath
Exit Function
End If
Next
End If
End Function
Function HtmlEncode(str)
HtmlEncode = SDB.toAscii(str)
HtmlEncode = Replace(HtmlEncode,"&","&")
HtmlEncode = Replace(HtmlEncode,"""",""")
HtmlEncode = Replace(HtmlEncode,"<","<")
HtmlEncode = Replace(HtmlEncode,">",">")
End Function[/code]