Music ticker for nearly any media player (including YouTube)

gustafsonk

New Member
GitHub: https://github.com/gustafsonk/SFMT
Download: https://github.com/gustafsonk/SFMT/archive/master.zip

(copy-pasted from GitHub)

Description
This script is intended to make it possible to share the currently playing song from your media player through a streaming program. It works by scraping the title of your media player's window, outputting the part you want to a file, and reading the file through a streaming program.

Supported Media Players?
Winamp, foobar2000, Spotify, YouTube (via web browser), MusicBee, MediaMonkey, VLC, WMP, iTunes, and any other media player that can display the currently playing song in the title of its window.

Supported Streaming Programs?
OBS, XSplit, FFsplit, and any other streaming program that can read text from a file.

Pros and Cons?
+ No dependency on any specific media player
+ Supports Unicode characters
+ Easy to trim junk off the beginning and end of a window title
+ Fix for padding out scrolling text in OBS
+ Multi-platform (untested, but use IronAHK instead of AutoHotkey_L)
+ Open-source, well-documented, and easy-to-edit
- No GUI for configuration (yet)

Instructions
1. Download and install AutoHotkey_L from http://www.autohotkey.com (should be the default one).
2. Save/Extract the SFMT.ahk file to your computer (ZIP button in the top left of GitHub).
3. Run this file by double-clicking on it to generate the output file, which is where your now playing song will be later. By default, it's "nowplaying.txt" and refreshes every 3 seconds.
4. Open your media player of choice and begin playing music.
5. Using your streaming program, add a text source for the output file.
6. Right-click the .ahk file, click Edit Script, and edit the CONFIGURE ME section for your media player/streaming program (see example below for help).
7. While configuring the file, you should perform the following workflow: edit the file, save the file, right-click the H icon in the system tray, click Reload This Script, and finally open the output file/preview the stream to see if it looks the way you want.

Example Configuration
First get the title of your media player's window. You can do this by hovering over the program in the taskbar or system tray and waiting a bit for text to appear. If you're having trouble with this or you can't find it, you can still figure it out by looking at the contents of the output file after you do this next step. This is an example title I see when playing a song in Winamp: "16. Carly Rae Jepsen - Call Me Maybe - Winamp".

Now you need to pick a part of the window title that will always be there while playing songs, which can usually be the program's name itself. In this example, "Winamp" will always be in the window's title so I can use that. Note that any other window with "Winamp" in it could interfere and be grabbed instead. Finally, place this value by the spot marked PART 1 in the CONFIGURE ME section. You can now perform Step 7 above to test if this part works for you.

Now you need to trim off the parts that you don't want to share on the stream, like the playlist number on the left and the media player's name on the right in this example. To trim the left side, identify the block of text closest to the left side of the untrimmed text that does not change from song to song. In this example, you could use " " (a space), or ". " (a period then space). Now, working from left-to-right, check if this block of text won't occur before you want; otherwise, it will trim from there instead. For example, if the title began with "Curiosity - 16. " and I was using " ", then it would trim off "Curiosity " when I wanted to trim off all of it. Using ". " instead would fix this problem. Many media players give you near full control over the look and ordering of the title elements so keep this in mind if you can't get what you want. To trim the right side, repeat this procedure working from right-to-left instead. In this example, I want to trim " - Winamp" so I can't use " ", but I can use " -" or even " - Winamp". Finally, place these values by the two spots marked PART 2 in the CONFIGURE ME section.

If you're using OBS to stream and scrolling the text, then you may want to edit PART 3 to make it look nicer. Other than that, you should be good to go and comfortable editing other things in the CONFIGURE ME section at the very least.
 

Jordendb

New Member
Re: Music ticker for nearly any media player (including YouT

Is it possible with Pandora?? :D
Its a website Player, and how to do it if its possible
 

Gaudion

New Member
Re: Music ticker for nearly any media player (including YouT

Is there a reason it won't generate the output file when I try to double click the script?
 

yatsuman

New Member
Re: Music ticker for nearly any media player (including YouT

How should I configure it for youtube, since the name of the window changes with every single song played from my playlist?
 

DoomStorm484

New Member
Re: Music ticker for nearly any media player (including YouT

Ok i am having trouble doing the config. I am using windows media player and i went though the whole thing step by step now about 4 times. and all i can get to show up in the nowplaying txt is windows media player. It is like it is not seeing the song title. I have even put nothing in the trim section to see if i was doing the trim wrong and i till only get Windows Media Player. Plz help this is what i have changed in the config part of the script.

Code:
; CONFIGURE ME (START)
  ; Getting the media player's window title, assumes no other window titles have this text
  windowTitle := "Windows Media Player"  ; PART 1: The media player's window title needs to always have this text
  SetTitleMatchMode 2  ; Look everywhere in window titles for a match, not just the beginning
  DetectHiddenWindows, on  ; Also check window titles minimized to the system tray

  ; Parsing the media player's window title, use "" to not trim one or both of the sides
  firstAfter := ""  ; PART 2: Everything left of the first instance of this and itself is trimmed
  lastBefore := ""  ; PART 2: Same idea above except this trims right and reads right-to-left

  ; Set the output file
  outputFile := "nowplaying.txt"

  ; Refresh rate in milliseconds for repeating this script
  refreshRate = 3000

  ; For scrolling text that wraps continuously without spacing (OBS), use "" to not use this
  scrollSeparator := " "  ; PART 3: Separate the first character from the last character
  AutoTrim, off  ; Leading/trailing space is ignored by AHK by default

  ; All 3 streaming programs can use UTF-8 to display Unicode characters
  FileEncoding, UTF-8
; CONFIGURE ME (END)
 

ChaosLegionaire

New Member
Re: Music ticker for nearly any media player (including YouT

Double Post

So I found out a solution for WMP. The problem is that the program is always just called "Windows Media Player". It never changes. The song data comes up in a separate tag above the program name. Because of this I had to install this plug-in;

http://bmproductions.fixnum.org/index.h ... g/wmpplus/

This puts the song title & artist into the Window title. Thus solving the problem... almost. You're still just going to get the same result as before. What you have to do now is in the SFMT file you will have to make the name "- Windows Media Player" . This way you get the new title and not the old one as we specified with the added hyphen. Now you should be getting the proper meta data.

Finally to pretty things up I trimmed the software name from the meta to make it look better. To do that edit the following;

; Parsing the media player's window title, use "" to not trim one or both of the sides
firstAfter := "" ; PART 2: Everything left of the first instance of this and itself is trimmed
lastBefore := "- Windows media player" ; PART 2: Same idea above except this trims right and reads right-to-left

Yes you do want to be that specific. Otherwide if you just do "- w" it might chop off the artist if you have an artist that starts with a W. Then again it goes right to left, so maybe not. It's late and I refuse to think that hard on the matter anymore, lol.

Anyways, this should now work for WMP if you follow these steps. Enjoy!!
 

latterlig

New Member
Re: Music ticker for nearly any media player (including YouT

Hi! Love this script! Only one question, im using scrolling text and spotify. And now the text shows for an example :
""- Eminem - Rap God Spotify-Eminem - Rap God Spotify-"" And just keeps on rolling.

Is there anyway i can remove the "Spotify" name from the scroll? And make the gaps between the same title comes again bigger? Cause now its just scrolling and scrolling.

Would be greate if it could be like : "" Eminem - Rap God Eminem - Rap God"" ??

Even greater if it could be made like this : ""Now playing : Eminem - Rap God"" (then like 10 sec pause, and again) "Now playing: Eminem - Rap God""

Best Regaards
 

rekon

New Member
Re: Music ticker for nearly any media player (including YouT

Hello everyone. Thanks for this script gustafsonk. For those wanting to use iheartradio.com via Google Chrome (I'm not sure about other web browsers) I have used the following code:

Code:
; CONFIGURE ME (START)
  ; Getting the media player's window title, assumes no other window titles have this text
  windowTitle := "♫"  ; PART 1: The media player's window title needs to always have this text
  SetTitleMatchMode 2  ; Look everywhere in window titles for a match, not just the beginning
  DetectHiddenWindows, on  ; Also check window titles minimized to the system tray

  ; Parsing the media player's window title, use "" to not trim one or both of the sides
  firstAfter := ""  ; PART 2: Everything left of the first instance of this and itself is trimmed
  lastBefore := " - Google Chrome"  ; PART 2: Same idea above except this trims right and reads right-to-left
This is simply what you put in parts 1 and 2. Copy and paste in the .ahk script and link the text file to your OBS.

For an example, check out my test stream: http://www.twitch.tv/rayqu0n/b/507324168
This script really is genius. It overwrites with blank text so there's no need to switch scenes or turn off text in OBS. So if you don't play music, nothing is shown. I'm going to try and figure out if one script can handle multiple windows such as reading youtube titles AND itunes windows. Will be interesting.

Thanks again!
 

Lunexar

New Member
I am very new to streaming and OBS. I am trying to use VLC Media Player with this script but can't get " - VLC media player" to not show when the title is scrolling .. example of how it looks . . Artist Song Title - VLC media player . . I cannot get rid of the " - VLC media player part tho. no clue what I am doing wrong . Any help greatly appreciated!!
 

Attachments

Reed

New Member
When I run the script, it says:

Error at line 89.
Line Text: FileEncoding, UTF-8
Error: This line does not contain a recognized action.

I can change the , to a = and the script runs fine and creates the output, but when OBS tried to read the text file, nothing comes out.
 

The_KDB

New Member
I tried this and I can't seem to get it to work. It creates the notepad file and changes the song, but isn't displaying correctly in OBS.

For some reason it only gives the title of whatever window is focused, even though I changed the config to only show spotify.

And also, when spotify is playing a song, it does not display any text whatsoever.

Has anyone ever run into this? How did you fix it?
 

exzacklyright

New Member
When I run the script, it says:

Error at line 89.
Line Text: FileEncoding, UTF-8
Error: This line does not contain a recognized action.

I can change the , to a = and the script runs fine and creates the output, but when OBS tried to read the text file, nothing comes out.
You have to be on the latest version of AHK. I had the same issue.


I can't seem to get GMusic working though...



woops.. just realized it has to be displayed in the window -.-
 
Last edited:
Top