It is currently May 7th, 2024, 12:30 pm

Automatic refreshing after Spotify song ends

Get help with creating, editing & fixing problems with skins
tanuki_raccoon
Posts: 3
Joined: April 26th, 2024, 5:11 pm

Automatic refreshing after Spotify song ends

Post by tanuki_raccoon »

How would you make it so the skin refreshes as soon as the Spotify song ends? Im using BMediaTaskbarWidget This is the code thats already in it:

Code: Select all

[Rainmeter]
Update=1
AccurateText=1
MiddleMouseUpAction=[!Refresh]
OnRefreshAction=[!CommandMeasure MeasureActionTimer "Execute 1"][!HideMeterGroup VolumeControl]

[Metadata]
Name=BTunes Taskbar Widget
Author=Blapman007
Information="Control your media, right from the taskbar."
Version=1
License=Creative Commons Attribution - Non - Commercial - Share Alike 3.0

[Variables]

;User Settings, these are for you :D
SpotiGreen=29,185,84
YoutubeRed=255,0,0
SoundCloudOrange=242,111,35
AlbumArtSize=45
TextClipWidth=200
TextClipHeight=20
TextFontSize=10
DetailsFontColor=0,0,0
SongDetailPositionX=48
SongDetailPositionY=8
ProgressBarPositionX=48
ProgressBarPositionY=33
ProgressBarWidth=310
ProgressBarThickness=5
FirstButtonPosition=58
ButtonSpacing=5R
ButtonHeight=6
HoverVolumeBGOpacity=200
VolumeLvFontSize=13
VolumeBtnSize=30
VolumeBtnPadding=10

; Marquee settings, these aren't for you :(
animationSpeed=32
marqueeBeginWait=1500
marqueeEndWait=1500

;Dynamic Vars, neither are these :(
marquee1=0
volopac1=1
ProgressBarCol=29,185,84

;MEASURES

;Get the player
[MeasurePlayer]
Measure=Plugin
Plugin=WebNowPlaying
PlayerType=PLAYER
;Set color of progress bar based on player name
;Assume Spotify
IfMatch=Windows Media Session|Spotify
IfMatchAction=[!SetVariable ProgressBarCol #SpotiGreen#]
;YouTube
IfMatch2=YouTube|Netflix
IfMatchAction2=[!SetVariable ProgressBarCol #YoutubeRed#]
;SoundCloud
IfMatch3=Soundcloud
IfMatchAction3=[!SetVariable ProgressBarCol #SoundCloudOrange#]

;Get the title
[MeasureTitle]
Measure=Plugin
Plugin=WebNowPlaying
PlayerType=TITLE
DynamicVariables=1
OnChangeAction=[!SetVariable marquee1 0][!CommandMeasure MeasureActionTimer "Execute 1"]

;Get the artist
[MeasureArtist]
Measure=Plugin
Plugin=WebNowPlaying
PlayerType=ARTIST
DynamicVariables=1

;Get the Duration
[MeasureDuration]
Measure=Plugin
Plugin=WebNowPlaying
PlayerType=DURATION
OnChangeAction=[!SetVariable marquee1 0][!CommandMeasure MeasureActionTimer "Execute 1"]
IfCondition=MeasureDuration < 1
IfTrueAction=[!Hide]
IfFalseAction=[!Show]

;Get the Progress
[MeasureProgress]
Measure=Plugin
Plugin=WebNowPlaying
PlayerType=PROGRESS

[MeasureState]
Measure=Plugin
Plugin=WebNowPlaying
PlayerType=STATE
Substitute="0":"#@#Images\play-fill.png","1":"#@#Images\pause-fill.png","2":"#@#Images\play-fill.png","3":"#@#Images\play-fill.png"
DynamicVariables=1


[MeasureMarquee1Offset]
Measure=Calc
Formula=max(0,([MeterDetails:W] - [MeterDetailContainer:W]))
DynamicVariables=1

[MeasureActionTimer]
Measure=Plugin
Plugin=ActionTimer
; Marquee 1
ActionList1=Repeat Move1,#animationSpeed#,[MeasureMarquee1Offset:] | Wait #marqueeEndWait# | Reset1 | Wait #marqueeBeginWait# | DoOver1
Reset1=[!SetVariable marquee1 0][!UpdateMeasure MeasureActionTimer][!UpdateMeter MeterDetails][!Redraw]
Move1=[!SetVariable marquee1 "(#marquee1# - 1)"][!UpdateMeasure MeasureActionTimer][!UpdateMeter MeterDetails][!Redraw]
DoOver1=[!CommandMeasure MeasureActionTimer "Execute 1"]
DynamicVariables=1

[MeasureAlbumArt]
Measure=Plugin
Plugin=WebNowPlaying
PlayerType=Cover
; The DefaultPath will be returned when no cover art has been found.
DefaultPath=#@#Images\nocover.png
UpdateDivider = 5

[MeasureVolume]
Measure=Plugin
Plugin=WebNowPlaying
PlayerType=Volume

;METERS

;Display Artist Name - Song NameS
[MeterDetails]
Meter=String
MeasureName=MeasureArtist
MeasureName2=MeasureTitle
AntiAlias=1
FontColor=#DetailsFontColor#
FontFace=Circular Std Medium
FontSize=#TextFontSize#
Text="%1 | %2"
X=#marquee1#
Y=2
Container=MeterDetailContainer
DynamicVariables=1

[MeterProgress]
Meter=Bar
MeasureName=MeasureProgress
X=#ProgressBarPositionX#
Y=#ProgressBarPositionY#
W=#ProgressBarWidth#
H=#ProgressBarThickness#
BarColor=#ProgressBarCol#
SolidColor=60,60,60,255
BarOrientation=Horizontal
DynamicVariables=1
LeftMouseUpAction=[!CommandMeasure MeasureTitle "SetPosition $MouseX:%$"][!UpdateMeasure MeasureTitle][!Redraw]

[MeterDetailContainer]
Meter=Shape
Shape=Rectangle 0,-5,#TextClipWidth#,#TextClipHeight#
Y=#SongDetailPositionY#
X=#SongDetailPositionX#

;[MeterContVis]
;Meter=Shape 
;Shape=Rectangle 0,-5,#TextClipWidth#,#TextClipHeight#

[MeterPrevious]
Meter=Image
ImageName=#@#Images\skip-back-fill.png
X=(#TextClipWidth# + #FirstButtonPosition#)
Y=#ButtonHeight#
LeftMouseUpAction=[!CommandMeasure MeasureTitle "Previous"]

[MeterPause]
Meter=Image
MeasureName=MeasureState
ImageName="#@#Images\pause-fill.png"
X=#ButtonSpacing#
Y=#ButtonHeight#
LeftMouseUpAction=[!CommandMeasure MeasureTitle "PlayPause"]

[MeterNext]
Meter=Image
ImageName=#@#Images\skip-forward-fill.png
X=#ButtonSpacing#
Y=#ButtonHeight#
LeftMouseUpAction=[!CommandMeasure MeasureTitle "Next"]

[MeterAlbumArt]
Meter=Image
h=#AlbumArtSize#
w=#AlbumArtSize#
MeasureName=MeasureAlbumArt
PreserveAspectRatio=1

[MeterVolumeBG]
Meter=Shape
Shape=Rectangle 0,0,(#TextClipWidth# + 1),#ProgressBarPositionY# | Fill Color 0,0,0,#volopac1# | StrokeWidth 0
X=#SongDetailPositionX#
Y=0
DynamicVariables=1
MouseActionCursorName="SIZE_WE"
MouseOverAction=[!SetVariable volopac1 #HoverVolumeBGOpacity#][!ShowMeterGroup VolumeControl]
MouseLeaveAction=[!SetVariable volopac1 1][!HideMeterGroup VolumeControl]
LeftMouseUpAction=[!CommandMeasure MeasurePlayer "SetVolume $MouseX:%$"]

[MeterVolumeLv]
Meter=String
MeasureName=MeasureVolume
AntiAlias=1
FontColor=255,255,255
FontFace=Circular Std Medium
FontSize=#VolumeLvFontSize#
StringAlign=CenterCenter
Text="%1"
X=(#SongDetailPositionX#+(#TextClipWidth# / 2))
Y=(#ProgressBarPositionY# / 2)
Group=VolumeControl

[MeterVolumeUp]
Meter=Image
ImageName=#@#Images\vpls.png
W=#VolumeBtnSize#
H=#VolumeBtnSize#
Group=VolumeControl
X=(((#TextClipWidth# + #SongDetailPositionX#) - #VolumeBtnSize#) - #VolumeBtnPadding#)

[MeterVolumeDn]
Meter=Image
ImageName=#@#Images\vmin.png
W=#VolumeBtnSize#
H=#VolumeBtnSize#
Group=VolumeControl
X=(#SongDetailPositionX# + #VolumeBtnPadding#)
I thought I could do it by when the progress meter gets to a certain value it refreshes, but I dont know how to do so.
RicardoTM
Posts: 272
Joined: December 28th, 2022, 9:30 pm
Location: México

Re: Automatic refreshing after Spotify song ends

Post by RicardoTM »

You could add

OnChangeAction=[!Refresh] to MeasureTitle

It would refresh when the song title changes.
tanuki_raccoon
Posts: 3
Joined: April 26th, 2024, 5:11 pm

Re: Automatic refreshing after Spotify song ends

Post by tanuki_raccoon »

That works! thanks! :thumbup:
User avatar
balala
Rainmeter Sage
Posts: 16201
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Automatic refreshing after Spotify song ends

Post by balala »

tanuki_raccoon wrote: April 26th, 2024, 5:24 pm How would you make it so the skin refreshes as soon as the Spotify song ends? Im using BMediaTaskbarWidget This is the code thats already in it:
Absolutely possible, as you saw on RicardoTM's reply, however I'd ask you why would you like to do this? So many refreshes are definitely not a too good idea.
tanuki_raccoon
Posts: 3
Joined: April 26th, 2024, 5:11 pm

Re: Automatic refreshing after Spotify song ends

Post by tanuki_raccoon »

So it will refresh the title of the widget so i dont have to do it myself
User avatar
Yincognito
Rainmeter Sage
Posts: 7207
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Automatic refreshing after Spotify song ends

Post by Yincognito »

tanuki_raccoon wrote: May 2nd, 2024, 12:12 am So it will refresh the title of the widget so i dont have to do it myself
What balala meant was that refreshing the entire skin instead of updating the necessary stuff in it is a bit overkill and not really necessary - to give a roughly similar example so you get the idea, it's like you'd always turn off and on your computer when you could just perform a Windows restart when needed. Plus, why do you even want to refresh the skin in the first place? From the looks of it, the skin should automatically provide the next song data as soon as the previous one ends and the next starts playing (and apparently, resets the marquee animation too in that moment, if I'm not mistaken). If I understood your objective correctly, that is.

If you really really want to do something similar to refreshing (but without starting over the whole skin), althoug like I said, I can't understand why since a similar effect should already be automatic, you could try:

Code: Select all

OnChangeAction=[!UpdateMeasure *][!UpdateMeter *][!Redraw][!CommandMeasure MeasureActionTimer "Stop 1"][!CommandMeasure MeasureActionTimer "Execute 1"][!HideMeterGroup VolumeControl]
I can't test this, but it should replicate the things that happen when you refresh the skin, without the unnecessary surplus.
Last edited by Yincognito on May 3rd, 2024, 12:41 pm, edited 1 time in total.
Reason: Removed newline in option value
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16201
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Automatic refreshing after Spotify song ends

Post by balala »

tanuki_raccoon wrote: May 2nd, 2024, 12:12 am So it will refresh the title of the widget so i dont have to do it myself
Let's clarify the terminology: you can't refresh the title, you can just refresh a whole skin. What you can do with the title is, as Yincognito mentioned above, an update, but this is a completely different operation. You initially asked for a complete refresh of the skin whenever Spotify ends a song. This is possible, but not desirable, because the refresh of a skin is a quite destructive operation and should be avoided, if possible. And in this case it is. So you don't need to refresh the skin (nor the title, what can't even be done), but to update the title (I assume by this you meant the title of the song). To achieve this, see Yincognito's above reply and note what he said as well, even if he didn't emphasize enough: if your skin has a normal update set in the [Rainmeter] section (in fact the Update of your skin is not quite alright, but it works at least - see below), the change of the title should go on without having to update the meter showing the title (even less without refreshing the skin).
Note that seeing how you did set Update value of the [Rainmeter] section (Update=1!!!), the skin updates once per 16 milliseconds. 16 milliseconds, because the lowest possible value for the Update option of the [Rainmeter] section is Update=16, you can't go below this (second paragraph here). In fact you can, but if you do so, the skin will still use the Update as Update=16. But such a low Update is needed only for skins having visualizer or animation (and you skin seems not to have none of these features). So you most probably by Update=1 meant one update per second (which is completely enough for this skin, unless I'm missing something) and this can be done by Update=1000 (one update per 1000 milliseconds = 1 second). Recommend you to replace this option and use the default Update=1000.