"now playing" to .txt-file

Post a reply

Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:

BBCode is ON
[img] is ON
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: "now playing" to .txt-file

Re: "now playing" to .txt-file

by Coincident » Wed Jul 20, 2022 8:36 pm

--> How can I setup a script to run when MediaMonkey exists?

The scripts in this thread are great! Thank you! I will use them while livestreaming on Twitch!

However, there's an improvement that I'm not sure how to get working...
My goal is to not keep showing the last played track on a livestream after closing down MM and not playing any audio.
I wrote a script to blank out the text file once MediaMonkey exists:

Code: Select all

    ' NowPlayingClearFile.vbs
    ' Clear the file that had current playing track and artist on exit
    option explicit

    sub NowPlayingClearFile

       dim objFSO, objTextFile, strTextFilePath

       'SET THIS TO LOCATION OF FILE
	   strTextFilePath = "C:\OBS Resources\nowplaying.txt"

       'Open the file & write
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      Set objTextFile = objFSO.CreateTextFile(strTextFilePath,2,-2)
      
	  On Error Resume Next
      
	  'Write nothing to leave the file empty
      
	  If Err.Number <> 0 Then
      objTextFile.WriteLine "Error"
      Err.Clear
      End If
	  
       'close the file   
       objTextFile.Close

    end sub
However, I don't know how to specify Scripts.ini in such a way that the script only runs on exit.
Is there an easy way to do this?

Thanks in advance.

Re: "now playing" to .txt-file

by Gehis514 » Sun Nov 29, 2020 9:16 am

Currently using this when I stream to twitch from obs and it's great for showing the songs i play. Since I know nothing about scripting myself, what would it look like if I wanted to output two text files, one for the track name and another for the artist name? It would allow me to do more creative and visually interesting things if they were in two separate files

Re: "now playing" to .txt-file

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?

Re: "now playing" to .txt-file

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.

Re: "now playing" to .txt-file

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

Re: "now playing" to .txt-file

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

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.

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).

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.

"now playing" to .txt-file

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?

Top