It is currently June 25th, 2019, 6:31 am

Nowplaying.dll to TXT

Discuss the use of Lua in Script measures.
Kobayen
Posts: 3
Joined: August 11th, 2017, 11:31 am

Nowplaying.dll to TXT

Kobayen » August 11th, 2017, 11:45 am

I wanted to know if anyone has ever written a script that takes the result string from NowPlaying.dll and send it to a txt file (so it can be captured and used by OBS). And if nobody had, how would one even start getting to do that?

I'm pretty sure this would involve scripting because of the file-writing part of the equation.
User avatar
dvo
Posts: 540
Joined: February 7th, 2016, 6:08 am

Re: Nowplaying.dll to TXT

dvo » August 11th, 2017, 3:48 pm

why don't you use screen capture ? then you have your things already in place :D
or try this.... https://sourceforge.net/projects/obsmusicstreamd/
Kobayen
Posts: 3
Joined: August 11th, 2017, 11:31 am

Re: Nowplaying.dll to TXT

Kobayen » August 11th, 2017, 5:32 pm

Window Capture needs to be set up every single time beforehand for a Photoshop stream, and Screen Capture assumes a given object will be drawn into the screen in a visible position at all times.

SMG stopped working for WinAMP for a while now, and newer versions where that bug is corrected are paid. 8 euro is quite an amount of cash in third-world-currency.
User avatar
dvo
Posts: 540
Joined: February 7th, 2016, 6:08 am

Re: Nowplaying.dll to TXT

dvo » August 11th, 2017, 5:50 pm

i can try to make something that does that but i'm a beginner so i have to try a lot to get it right some script i can handle... :D
but could winamp not write the info some how ... have to look in to that to maybe the better way :D

otherway :https://sourceforge.net/p/streamripper/discussion/19083/thread/b20cf24f/
and winamp is in restyle so all is gone searching the web could help :oops:

or this :P

http://brandon.fuller.name/archives/2007/01/21/17.15.20/#download :bow: :rolmfao:
this outputs with nowplaying plugin installed a xml (this didn't work with mine )

C:\Program Files (x86)\Winamp\Plugins\Now Playing\now_playing.xml :rolmfao: :great: :welcome:
Kobayen
Posts: 3
Joined: August 11th, 2017, 11:31 am

Re: Nowplaying.dll to TXT

Kobayen » August 11th, 2017, 7:21 pm

In the end, you solved my problem but not Quite the way I expected! :D Fuller's NowPlaying doesnt work for OBS (for a variety of reasons) but googling its name directed me to AMIP ( http://amip.tools-for.net/wiki/start ) -- which does have an option to output things to a text file the way OBS can actually use!

So, thanks for saving us both alot of needless work and worry. And 8 Euro. :bow:
User avatar
dvo
Posts: 540
Joined: February 7th, 2016, 6:08 am

Re: Nowplaying.dll to TXT

dvo » August 12th, 2017, 2:12 pm

your welome :) :D
FlyingHyrax
Posts: 251
Joined: July 1st, 2011, 1:32 am
Location: US

Re: Nowplaying.dll to TXT

FlyingHyrax » August 13th, 2017, 1:38 am

I see your problem is already solved, but just for future reference in case someone searches their way upon this thread - I do think this is doable with Lua.

Here's a quick and dirty script that takes the string value from a measure and appends it to a file:

Code: Select all

function Initialize()
    measureToSave = SKIN:GetMeasure(SELF:GetOption('MeasureToSave'))
    writeOnUpdate = SELF:GetNumberOption('WriteOnUpdate') == 1
    logFilePath = SKIN:MakePathAbsolute(SELF:GetOption('FileToWrite', 'default_log.txt'))
end

function Update()
    if writeOnUpdate then
        WriteMeasureValue()
    end
end

function WriteMeasureValue()
    local strVal = measureToSave:GetStringValue()
    local theFile = io.open(logFilePath, 'a')
    theFile:write(strVal .. "\n")
    theFile:close()
end

...and here is a corresponding skin that uses that script to write the current track name any time the track changes with the NowPlaying plugin:

Code: Select all

[Rainmeter]
Update=1000
MiddleMouseUpAction=[!Refresh]

[measureTrackname]
Measure=Plugin
Plugin=NowPlaying
PlayerName=CAD
PlayerType=Title
TrackChangeAction=[!CommandMeasure "measureWriteToFile" "WriteMeasureValue()"]

[measureWriteToFile]
Measure=Script
ScriptFile=.\save_measure_value.lua
MeasureToSave="measureTrackname"
FileToWrite="log.txt"
WriteOnUpdate=0

[meterTrackname]
Meter=String
MeasureName=measureTrackname
X=0
Y=0
W=200
H=25
SolidColor=0,0,0,100
FontSize=12
FontColor=255,255,255
ClipString=1
AntiAlias=1

The script could pretty easily be extended and cleaned up to add more flexibility, like writing the number value instead of the string value, writing to the top instead of the bottom of the text file, adding a prefix or suffix around the string written to the log, etc.
Flying Hyrax on DeviantArt
User avatar
MarcoPixel
Posts: 39
Joined: June 8th, 2012, 9:43 am
Location: Austria

Re: Nowplaying.dll to TXT

MarcoPixel » December 15th, 2017, 9:47 pm

You could also use Snip for OBS, they pretty much support all major players except AIMP afaik.