It is currently December 15th, 2019, 6:26 am

Please help, music in rainmeter

Get help with installing and using Rainmeter.
Tact1cal
Posts: 1
Joined: September 19th, 2019, 1:32 am

Please help, music in rainmeter

Tact1cal » September 19th, 2019, 1:37 am

Hello there, thanks for clicking on this post, it would mean a lot to me if someone helped me out on this problem: I want a certain song to start playing when I power on my PC. Is there anyway of doing this, If so how? Perferably through a downloaded song or YouTube Music or something like that. Would mean the world if someone helped me. Thanks :)
User avatar
eclectic-tech
Rainmeter Sage
Posts: 3645
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Please help, music in rainmeter

eclectic-tech » September 19th, 2019, 1:10 pm

It is possible to perform an action 1 time when a skin is loaded by using this code. The key is the "Counter" variable which starts to count from zero when the skin is loaded, and is only reset when the skin re-loads (not on updates or refresh). The "IfAboveAction=" bang will fire 1 time to do anything you want.

This will open a youtube page, but you need to click the page to play.

Code: Select all

[RunOnceYouTube]
Measure=Calc
Formula=Counter
IfEqualValue=1
IfEqualAction=["https://www.youtube.com/watch?v=fRL447oDId4"]
IfAboveValue=1
IfAboveAction=[!DisableMeasure RunOnceYouTube]

[MeterDummy]
Meter=String
This will play the Windows 10 Logon sound.

Code: Select all

[RunOnceWav]
Measure=Calc
Formula=Counter
IfEqualValue=1
IfEqualAction=[Play "chord.wav"]
IfAboveValue=1
IfAboveAction=[!DisableMeasure RunOnceWav]

[MeterDummy]
Meter=String
Evey skin must have at least 1 meter to be valid, so a "Dummy" string meter was added to each example.
(RunOnce suggested by JSMorley, of course! :) )
User avatar
jsmorley
Developer
Posts: 19870
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Please help, music in rainmeter

jsmorley » September 20th, 2019, 2:19 pm

Here is one that will play any .mp3 file without opening any bulky player or a separate window.
It requires a small external executable, which is included in the .rmskin.

https://lawlessguy.wordpress.com/2015/06/27/update-to-a-command-line-mp3-player-for-windows/

PlayMP3_1.1.rmskin

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Metadata]
Name=PlayMP3
Author=JSMorley
Information=Uses the external cmdmp3win.exe to play any .mp3 file.
Version=Sep 20, 2019
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0

[Variables]
Song=#@#Songs\Vienna Teng - Lullabye for a Stormy Night.mp3
Player=#@#cmdmp3\cmdmp3win.exe

[MeasureKill]
Measure=Plugin
Plugin=RunCommand
Parameter=taskkill /IM "cmdmp3win.exe" /F
State=Hide

[RunOnceMP3]
Measure=Calc
Formula=Counter
IfEqualValue=1
IfEqualAction=[!CommandMeasure MeasureKill "Run"][!Delay 500]["#Player#" "#Song#"]
IfAboveValue=1
IfAboveAction=[!DisableMeasure RunOnceMP3]

[MeterPlay]
Meter=Image
W=25
H=25
SolidColor=101,244,0,255
LeftMouseUpAction=[!CommandMeasure MeasureKill "Run"][!Delay 500]["#Player#" "#Song#"]

[MeterStop]
Meter=Image
X=5R
W=25
H=25
SolidColor=255,45,7,255
LeftMouseUpAction=[!CommandMeasure MeasureKill "Run"]
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 19870
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Please help, music in rainmeter

jsmorley » September 20th, 2019, 2:53 pm

Note that cmdmp3win.exe does not run in an "exclusive" mode, so you can easily get a cacophonous "row, row, row your boat" round going if you play the song repeatedly. You can avoid this by having the command to play the song be:

[taskkill /IM "cmdmp3win.exe" /F]["#Player#" "#Song#"]

So it stops any currently playing songs before it starts a new one.

Also note that the taskkill.exe command is a built-in external cmd/dos command that will very briefly open a cmd window when executed. This can be avoided by using the RunCommand plugin to execute it, if you like.

https://docs.rainmeter.net/manual/plugins/runcommand/
User avatar
jsmorley
Developer
Posts: 19870
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Please help, music in rainmeter

jsmorley » September 20th, 2019, 3:03 pm

So maybe a more robust version might be:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Metadata]
Name=PlayMP3
Author=JSMorley
Information=Uses the external cmdmp3win.exe to play any .mp3 file.
Version=Sep 20, 2019
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0

[Variables]
Song=#@#Songs\Vienna Teng - Lullabye for a Stormy Night.mp3
Player=#@#cmdmp3\cmdmp3win.exe

[MeasureKill]
Measure=Plugin
Plugin=RunCommand
Parameter=taskkill /IM "cmdmp3win.exe" /F
State=Hide

[RunOnceMP3]
Measure=Calc
Formula=Counter
IfEqualValue=1
IfEqualAction=[!CommandMeasure MeasureKill "Run"][!Delay 500]["#Player#" "#Song#"]
IfAboveValue=1
IfAboveAction=[!DisableMeasure RunOnceMP3]

[MeterPlay]
Meter=Image
W=25
H=25
SolidColor=101,244,0,255
LeftMouseUpAction=[!CommandMeasure MeasureKill "Run"][!Delay 500]["#Player#" "#Song#"]

[MeterStop]
Meter=Image
X=5R
W=25
H=25
SolidColor=255,45,7,255
LeftMouseUpAction=[!CommandMeasure MeasureKill "Run"]
Updated the .rmskin above to reflect this...