It is currently April 19th, 2024, 9:36 am

Music player - Centre title

Get help with creating, editing & fixing problems with skins
tnt6200
Posts: 5
Joined: November 7th, 2011, 8:02 am

Music player - Centre title

Post by tnt6200 »

I'm making a music player, and everything was going according to plan until I tried to centre the artist and title strings...I made a script to do so but can't seem to make it keep the information centred. I tried TrackChangeAction but that didn't work. I also tried making it run when the progress was = 0 but that didn't work either. :confused:

Code: Select all

[Rainmeter]
Update=100
DynamicWindowSize=1

[Variables]
@Include=#ROOTCONFIGPATH#variables.inc


;MEASURES
[MeasurePosition]
Measure=Plugin
Plugin=NowPlaying
PlayerName=#PlayerName#
PlayerType=Position

[MeasureProgress]
Measure=Plugin
Plugin=NowPlaying
PlayerName=[MeasurePosition]
PlayerType=Progress

[MeasureDuration]
Measure=Plugin
Plugin=NowPlaying
PlayerName=[MeasurePosition]
PlayerType=Duration

[MeasureTitle]
Measure=Plugin
Plugin=NowPlaying
PlayerName=[MeasurePosition]
PlayerType=Title

[MeasureArtist]
Measure=Plugin
Plugin=NowPlaying
PlayerName=[MeasurePosition]
PlayerType=Artist

[MeasureRepeat]
Measure=Plugin
Plugin=NowPlaying
PlayerName=[MeasurePosition]
PlayerType=Repeat
Substitute="0":"repeat.png","1":"repeat1.png"

[MeasureShuffle]
Measure=Plugin
Plugin=NowPlaying
PlayerName=[MeasurePosition]
PlayerType=Shuffle
Substitute="0":"shuffle.png","1":"shuffle1.png"

[MeasureState]
Measure=Plugin
Plugin=NowPlaying
PlayerName=[MeasurePosition]
PlayerType=State
Substitute="0":"play.png","1":"pause.png","2":"play.png"

[MeasureVolume]
Measure=Plugin
Plugin=NowPlaying
PlayerName=[MeasurePosition]
PlayerType=Volume
IfAboveValue=#PlayerVolume#
IfAboveAction=!CommandMeasure MeasureVolume "SetVolume #PlayerVolume#"
IfBelowValue=#PlayerVolume#
IfBelowAction=!CommandMeasure MeasureVolume "SetVolume #PlayerVolume#"

[MeasureSystemVolume]
Measure=Plugin
Plugin=Win7AudioPlugin


;METERS
[MeterScrubber]
Meter=Image
H=13
W=263
SolidColor=0,0,0,1
MouseScrollDownAction=!CommandMeasure MeasurePosition "SetPosition -2"
MouseScrollUpAction=!CommandMeasure MeasurePosition "SetPosition +2"
LeftMouseUpAction=!CommandMeasure MeasurePosition "OpenPlayer"
MouseActionCursor=0

[MeterPosition]
Meter=String
MeasureName=MeasurePosition
MeterStyle=Style

[MeterProgress]
MeasureName=MeasureProgress
Meter=Bar
X=30
Y=6
W=200
H=1
BarColor=136,178,219
SolidColor=255,255,255
BarOrientation=Horizontal

[MeterDuration]
Meter=String
MeasureName=MeasureDuration
X=5R
MeterStyle=Style

[MeterTitle]
Meter=String
MeasureName=MeasureTitle
MeterStyle=Style
Y=14


[MeterRepeat]
Meter=Image
ImageName=#@#\Images\[MeasureRepeat]
X=23
Y=30
DynamicVariables=1
LeftMouseUpAction=!CommandMeasure MeasurePosition "SetRepeat -1"
SolidColor=0,0,0,1

[MeterRewind]
Meter=Image
ImageName=#@#\Images\rw.png
X=69
Y=30
LeftMouseUpAction=!CommandMeasure MeasurePosition "Previous"
SolidColor=0,0,0,1

[MeterPlay]
Meter=Image
ImageName=#@#\Images\[MeasureState]
X=124
Y=30
DynamicVariables=1
LeftMouseUpAction=!CommandMeasure MeasurePosition "PlayPause"
SolidColor=0,0,0,1

[MeterForward]
Meter=Image
ImageName=#@#\Images\ff.png
X=39R
Y=30
LeftMouseUpAction=!CommandMeasure MeasurePosition "Next"
SolidColor=0,0,0,1

[MeterShuffle]
Meter=Image
ImageName=#@#\Images\[MeasureShuffle]
X=222
Y=30
DynamicVariables=1
LeftMouseUpAction=!CommandMeasure MeasurePosition "SetShuffle -1"
SolidColor=0,0,0,1

[MeterArtist]
Meter=String
MeasureName=MeasureArtist
MeterStyle=Style
Y=1R

[MeterSlider]
Meter=Image
H=14
W=263
Y=62
SolidColor=0,0,0,1
MouseScrollDownAction=!CommandMeasure MeasureSystemVolume "ChangeVolume -2"
MouseScrollUpAction=!CommandMeasure MeasureSystemVolume "ChangeVolume 2"
LeftMouseUpAction=!CommandMeasure MeasureSystemVolume "ToggleMute"
MouseActionCursor=0

[MeterVolumeLower]
Meter=Image
ImageName=#@#\Images\mute.png
X=10
Y=61

[MeterSystemVolume]
MeasureName=MeasureSystemVolume
Meter=Bar
X=5R
Y=68
W=200
H=1
BarColor=136,178,219
SolidColor=255,255,255
BarOrientation=Horizontal

[MeterVolumeRaise]
Meter=Image
ImageName=#@#\Images\sound.png
X=10R
Y=61


;SCRIPTS
[MeasureScript]
Measure=Script
ScriptFile=#@#\Measures\Music.lua

Code: Select all

function CentreText()
	local Artist = SKIN:GetMeter('MeterArtist')	
	local ArtistW = Artist:GetW()
	local Title = SKIN:GetMeter('MeterTitle')
	local TitleW = Title:GetW()
		
	local NewArtistX = (263 - ArtistW)/2
	local NewTitleX = (263 - TitleW)/2
	
	Artist:SetX(NewArtistX)
	Title:SetX(NewTitleX)
end
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5391
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Music player - Centre title

Post by eclectic-tech »

Why not just override the style settings with StringAlign=Center?

Code: Select all

[MeterTitle]
Meter=String
MeasureName=MeasureTitle
MeterStyle=Style
X=131
Y=14
W=263
H=18
StringAlign=Center
ClipString=1

[MeterArtist]
Meter=String
MeasureName=MeasureArtist
MeterStyle=Style
X=131
Y=1R
W=263
H=18
StringAlign=Center
ClipString=1
tnt6200
Posts: 5
Joined: November 7th, 2011, 8:02 am

Re: Music player - Centre title

Post by tnt6200 »

I was under the impression that that wouldn't work because the width will vary...I'll try when I get home tonight.
tnt6200
Posts: 5
Joined: November 7th, 2011, 8:02 am

Re: Music player - Centre title

Post by tnt6200 »

Well...it worked. Looking back now, I can't see any reason why it wouldn't. I guess it was just too late at night for me to think straight. :?
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5391
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Music player - Centre title

Post by eclectic-tech »

tnt6200 wrote:Well...it worked. Looking back now, I can't see any reason why it wouldn't. I guess it was just too late at night for me to think straight. :?
I've been there... and done that too! :lol: