"now playing" to .txt-file

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

loket
Posts: 4
Joined: Wed Sep 22, 2004 6:14 pm

"now playing" to .txt-file

Post by loket » Tue Oct 12, 2004 6:15 am

i have been using a mirc-script in winamp to create a .txt-file which consists of only one line:

Code: Select all

 <artist> - "<title>"
whenever a new song is played, the .txt-file is updated with the current artist and song. i can then use this file to integrate in other programs, without necessarily "speaking" with mediamonkey.
is this possible to do with only mm? i'm experiencing some bugs with mm and winamp together, and i want to use mm as the only application.

anyone?

Lowlander
Posts: 46497
Joined: Sat Sep 06, 2003 5:53 pm
Location: MediaMonkey 5

Post by Lowlander » Mon Oct 18, 2004 3:47 pm

What's the purpose of this list? You might be able to generate it out of the DB directly.

I'm not sure if MM can write info to script on song change, which would be needed in your case.
Lowlander (MediaMonkey user since 2003)

parkint
Posts: 16
Joined: Sat Oct 09, 2004 1:54 am

Post by parkint » Thu Nov 11, 2004 2:18 pm

This should be possible, and in fact pretty easy.

You just need to set ScriptType=2 in Scripts.ini for the script to be called at song change time.

I'll write the script for you if you can wait until tomorrow evening (GMT).

parkint
Posts: 16
Joined: Sat Oct 09, 2004 1:54 am

Post by parkint » Thu Nov 11, 2004 5:03 pm

OK, I think this should do what you want.

Save the following in your mediamonkey scripts directory:

Code: Select all

' OutputTextFile.vbs
' Write the current playing track and artist to a text file
option explicit

sub OutputTextFile

	dim objFSO, objTextFile, strTextFilePath, strTrack, strArtist

	'SET THIS TO LOCATION OF FILE
	strTextFilePath = "d:\scratch\mm_output.txt"


	'Get the artist/track
	strTrack = SDB.Player.CurrentSong.Title
	strArtist = SDB.Player.CurrentSong.Artist.Name

	'Open the file & write
	Set objFSO = CreateObject("Scripting.FileSystemObject") 
	Set objTextFile = objFSO.OpenTextFile(strTextFilePath,2)

	objTextFile.WriteLine strArtist & " - " & chr(34) & strTrack & chr(34)		

	'close the file	
	objTextFile.Close

end sub
And add the following to Scripts.ini in the same directory:

Code: Select all


[OutputTextFile]
FileName=OutputTextFile.vbs
ProcName=OutputTextFile
Language=VBScript
ScriptType=2
One gotcha is that I haven't included any check for the existence of the output file so you will have to create that first or the script will fall over.

Euther
Posts: 1
Joined: Sat Feb 28, 2015 1:06 pm

Re: "now playing" to .txt-file

Post by Euther » Sat Feb 28, 2015 1:12 pm

Hi,
this is exactily what I am looking for too... :D
I want to add the Album info and did the following... But it errors out with an error on Line 15: Column:3
"Object doesn't support this property of method"

Can someone please assist?
thx
E

Code: Select all

' OutputTextFile.vbs
' Write the current playing track and artist to a text file option explicit

sub OutputTextFile

   dim objFSO, objTextFile, strTextFilePath, strTrack, strArtist, strAlbum

   'SET THIS TO LOCATION OF FILE
   strTextFilePath = "O:\OSB Addons\Now Playing\mm_output.txt"


   'Get the artist/track/album
   strTrack = SDB.Player.CurrentSong.Title
   strArtist = SDB.Player.CurrentSong.Artist.Name
   strAlbum = SDB.Player.CurrentSong.Album

   'Open the file & write
   Set objFSO = CreateObject("Scripting.FileSystemObject") 
   Set objTextFile = objFSO.OpenTextFile(strTextFilePath,2)

   'objTextFile.WriteLine strArtist & " - " & chr(34) & strTrack & chr(34) & " - " & chr(34) & strAlbum & chr(34)

   'close the file   
   objTextFile.Close

end sub

kireev20000
Posts: 1
Joined: Sun Mar 06, 2016 8:44 am

Re: "now playing" to .txt-file

Post by kireev20000 » Sun Mar 06, 2016 8:46 am

replace code in OutputTextFile.vbs

Version for OBS txt plug-in (no unicode support)

Code: Select all

    ' OutputTextFile.vbs
    ' Write the current playing track and artist to a text file
    option explicit

    sub OutputTextFile

       dim objFSO, objTextFile, strTextFilePath, strTrack, strArtist, strAlbum

       'SET THIS TO LOCATION OF FILE
	   strTextFilePath = "e:\Soft\_MediaMonkey\obs_song.txt"


       'Get the artist/track
       strTrack = SDB.Player.CurrentSong.Title
       strArtist = SDB.Player.CurrentSong.Artist.Name
       strAlbum = SDB.Player.CurrentSong.AlbumName

       'Open the file & write
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      If (objfso.FileExists(strTextFilePath)) Then
	   	  Set objTextFile = objFSO.OpenTextFile(strTextFilePath,2)
      Else
	      Set objTextFile = objFSO.CreateTextFile(strTextFilePath,2)
      End If

	  On Error Resume Next
      
	  If strArtist = "" Then  
      objTextFile.WriteLine "Music: " & strTrack & " /" & strAlbum & "/" 
	  Else 
	  objTextFile.WriteLine "Music: " & strArtist & " - " & strTrack & " /" & strAlbum & "/"
      End If
      
	  If Err.Number <> 0 Then
      objTextFile.WriteLine "Error: Unicode Text"
      Err.Clear
      End If
        
	  
       'close the file   
       objTextFile.Close
       

    end sub

With Unicode Support

Code: Select all

    ' OutputTextFile.vbs
    ' Write the current playing track and artist to a text file
    option explicit

    sub OutputTextFile

       dim objFSO, objTextFile, strTextFilePath, strTrack, strArtist, strAlbum

       'SET THIS TO LOCATION OF FILE
	   strTextFilePath = "e:\Soft\_MediaMonkey\obs_song.txt"


       'Get the artist/track
       strTrack = SDB.Player.CurrentSong.Title
       strArtist = SDB.Player.CurrentSong.Artist.Name
       strAlbum = SDB.Player.CurrentSong.AlbumName

       'Open the file & write
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      Set objTextFile = objFSO.CreateTextFile(strTextFilePath,2,-2)
      
	  On Error Resume Next
      
	  If strArtist = "" Then  
      objTextFile.WriteLine "Music: " & strTrack & " /" & strAlbum & "/" 
	  Else 
	  objTextFile.WriteLine "Music: " & strArtist & " - " & strTrack & " /" & strAlbum & "/"
      End If
      
	  If Err.Number <> 0 Then
      objTextFile.WriteLine "Error"
      Err.Clear
      End If
        
	  
       'close the file   
       objTextFile.Close
       

    end sub


The_Testy_Ferrets

Re: "now playing" to .txt-file

Post by The_Testy_Ferrets » Sun Nov 03, 2019 8:09 am

I know this is an old thread but Bump, Doing some streaming and people ask who is playing, this simple script solved all of that so quickly.

It would be a good idea to get this added as a streamer option.

Peke
Posts: 12697
Joined: Tue Jun 10, 2003 7:21 pm
Location: Serbia
Contact:

Re: "now playing" to .txt-file

Post by Peke » Sat Nov 09, 2019 8:28 pm

Hi,
Can you please give us more details what you use and how you solved it?
Best regards,
Pavle
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
How to add SCREENSHOTS to forum

Post Reply