i2002 / RainmeterMediaPlayer

Plugin for Rainmeter to get now playing info from Windows 10 API
GNU General Public License v3.0
13 stars 1 forks source link

Artist doesn't appear when music starts playing #5

Closed OmarRamirez1603 closed 7 months ago

OmarRamirez1603 commented 8 months ago

Hi i2002 great work with your meter, I am creating one of my own and I noticed that the Artist's text doesn't show up until the song is changed. If you try to open Spotify without playing or changing the song, the artist's text won't show up until you change the song. Do you know if there is any possible fix for this?

OmarRamirez1603 commented 8 months ago

I just tried this and it returns the title instead of the artist

[StateMeasure] Measure=Plugin Group=Measures Plugin=MediaPlayer PlayerName=Default PlayerType=State IfCondition=(StateMeasure <> 0) IfTrueAction=[!SetOption ArtistMeter Text [ArtistMeasure]] OnUpdateAction=[!UpdateMeter ArtistMeter][!Redraw]

It may be that the plugin just doesn't return the artist until the song is changed. I also opened the rain meter log to see the values of the measures and the Artist's measure doesn't have a value. At least until the song is changed. image

OmarRamirez1603 commented 8 months ago

I think it's an issue with Spotify, I tried playing a song on YouTube and it worked perfectly without switching songs. Can you confirm this issue or help me think of a solution? PD: Sorry for so many comments I typed them while trying out stuff.

i2002 commented 8 months ago

Hi,

I can confirm this also happens for me, however I believe it's a Spotify issue. The artist is missing also from the sound volume popup (which uses the same API), so that would mean that Spotify is not reporting the correct information to the API for the first song it plays. image

If I change the song, the artist now appears as it should. image

So if Spotify doesn't give the correct value, there is nothing I can do on the plugin part to find it.

OmarRamirez1603 commented 8 months ago

Hey man thank you for your answer I appreciate it. I was wondering if you could help me with a modification I want to do to the code. I want to display the Artist and the Album Together like this "Artist - Album", but if they are the same I only want to display the Artist like this "Artist" and if there's no artist just the album like this "Album" and finally none of them if they are both the same and there's no Artist Info.

I got this code working but I think there should be a better and complete solution. I also tried if statements but couldn't get them working I see you use the IfMatch property, maybe there's a way to do it with that property?

[mAlbum] Measure=Plugin Plugin=#PluginName# PlayerType=Album Substitute="[mTitle]":"","[mAlbum]":" - [mAlbum]" DynamicVariables=1

[ConditionalMeter] Meter=String MeasureName=mArtist MeasureName2=mAlbum Text=%1%2 FontFace=Arial FontSize=15 FontColor=255,0,0 X=10 Y=10

i2002 commented 7 months ago

Hi,

I'm sorry, I intended to check on later on the question but it seems I forgot.

Yeah, I use IfMatch for the cover image.

[mCover]
Measure=Plugin
Plugin=#PluginName#
PlayerType=Cover

IfMatch=.+
IfNotMatchAction=[!HideMeter Cover][!ShowMeter DefaultCover]
IfMatchAction=[!ShowMeter Cover][!HideMeter DefaultCover]

The way it works is I have two image meters, one that shows the image returned from the api and one that shows the default image. IfMatch checks if the measure data is not empty (.+ is RegEx for at least a character, therefore not empty) and I trigger actions to hide one of the image meters and show the other.

You can also find a similar example in Rainmeter docs: https://docs.rainmeter.net/manual/measures/general-options/ifmatchactions/ (which uses SetOption instead of Show / Hide).

Hope it helps