It is currently September 1st, 2024, 2:46 am

Playing Sounds on Left Click/Hover

Get help with creating, editing & fixing problems with skins
Eldestbear
Posts: 5
Joined: May 19th, 2024, 4:20 am

Playing Sounds on Left Click/Hover

Post by Eldestbear »

I'm fairly new to this style of coding can someone please explain to me what I'm doing wrong; I can't seem to get the sound to play, and I've tried a few different ways (The sound is in the skin folder, not it's own folder)

Code: Select all

[Rainmeter]
Update=25

[Metadata]
Name=Image Launcher
Author=hmmmmm
Information=0
License=Imadethis
Version=69.0

[Variables]
@include=[Image Launcher]
SoundFile=Open.wav

[Dock]
meter=Image
ImageName=dock.png
x=0
y=0

; ===========App1===========

[AppButton1Passive]
x=25
y=18
Meter=Image
ImageName=apexbanner.jpg
MouseOverAction=!Execute [!ShowMeter AppButton1Active][!HideMeter AppButton1Passive][!Update]

[AppButton1Active]
x=40r
y=r
Meter=Image
ImageName=apexbanner.jpg
LeftMouseUpAction=!Execute ["C:\Program Files (x86)\Steam\steamapps\common\Apex Legends\r5apex.exe"][!ShowMeter AppButton1Passive][!HideMeter AppButton1Active][!Update]
LeftMouseUpAction=[Play "Open.wav"]
MouseLeaveAction=!Execute [!ShowMeter AppButton1Passive][!HideMeter AppButton1Active][!Update]
Last edited by balala on May 19th, 2024, 2:22 pm, edited 1 time in total.
Reason: Please use <code> tags whenever are you posting codes. It's the </> button.
Eldestbear
Posts: 5
Joined: May 19th, 2024, 4:20 am

Re: Playing Sounds on Left Click/Hover

Post by Eldestbear »

Ok, so I figured out one mistake, I should have put [Play #SoundFile#] Instead of the file name, AND I moved the play action to the same line as the other Left click functions. Now all I'm getting is an actually system error sound when I click on the skin, not the sound I want to play. Any thoughts?
User avatar
balala
Rainmeter Sage
Posts: 16485
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Playing Sounds on Left Click/Hover

Post by balala »

Eldestbear wrote: May 19th, 2024, 2:06 pm Now all I'm getting is an actually system error sound when I click on the skin, not the sound I want to play. Any thoughts?
Yep, in such a case, the sound file is not available. Where are you storing the Open.wav file? It should be near the .ini file of your skin, but I assume it's not there.
Eldestbear
Posts: 5
Joined: May 19th, 2024, 4:20 am

Re: Playing Sounds on Left Click/Hover

Post by Eldestbear »

everything is kept in the same folder because I'm not good with including source folders yet. When I go into rainmeters log, it recognizes Open.wav as a variable, so it's in the right place, windows just won't play the sound for some reason.
User avatar
balala
Rainmeter Sage
Posts: 16485
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Playing Sounds on Left Click/Hover

Post by balala »

Eldestbear wrote: May 19th, 2024, 2:33 pm everything is kept in the same folder because I'm not good with including source folders yet. When I go into rainmeters log, it recognizes Open.wav as a variable, so it's in the right place, windows just won't play the sound for some reason.
In this case pack please the whole config you have (the folder containing both, the skins .ini and the .wav file and if there are others, those files as well) and upload tha package here. I'd like to check it.
Eldestbear
Posts: 5
Joined: May 19th, 2024, 4:20 am

Re: Playing Sounds on Left Click/Hover

Post by Eldestbear »

I've included just the first banner because that's all you really need I think. All the rest are just a copy/paste and swapping the numbers around.
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 16485
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Playing Sounds on Left Click/Hover

Post by balala »

Eldestbear wrote: May 19th, 2024, 7:50 pm I've included just the first banner because that's all you really need I think. All the rest are just a copy/paste and swapping the numbers around.
Would have been much better you were creating the package, containing the whole config, just to have all resources (images for instance), but it's good this way as well. Checked and you were right: the file is not played. Most probably there is a codec or some similar issue. I finally converted the file, getting a working file, which is played now here. Hope you get it working as well. Attaching the converted Open.wav. Please download and try using it. Does work?

Additional tips:
  • Remove the !Execute bangs. They used to be used long time ago, but in meantime it became deprecated and there is no need to use it.
  • When you're showing or hiding meters (by !HideMeter and !ShowMeter bangs), there is no need to update the whole skin. You did so in the MouseOverAction and MouseLeaveAction options of all meters, adding a [!Update] bang to the end of all those options. Recommend to replace these [!Update] bangs by [!Redraw]. It is completely enough to redraw the skin when you're showing / hiding meters, no need to completely update it.
  • It is strongly recommended to store all resources (sounds, images and so on) into the @Resources folder. You have all these files into the config of your skin, but would be better to create a @Resources folder into the root config (the first folder into the Skins folder, which contains the .ini file of your skin), move all those resources there and add a #@# variable before all options containing a resource. For instance if you did this (so you have for example the dock.png file, used into the [Dock] meter, moved to @Resources), replace the ImageName option of the above mentioned [Dock] meter by ImageName=#@#dock.png. Even if it works with files placed to the root config, storing them into @Resources is a long time ago recommended practice.
You do not have the required permissions to view the files attached to this post.
Eldestbear
Posts: 5
Joined: May 19th, 2024, 4:20 am

Re: Playing Sounds on Left Click/Hover

Post by Eldestbear »

It works! When I originally downloaded that sound it was an .mp3 file. I didn't actually convert it, I just renamed the file to be.wav, which in hindsight I realize doesn't do what it should have done. So thanks for that!

In regard to all the bans that I can rework or get rid of, that's good to know! I copied a small amount of the coding from other launchers (that are fairly old as you've said), so that's why there's a lot of older code in there. I'll rework it slowly and make those changes!

Thank you so much!!!
User avatar
balala
Rainmeter Sage
Posts: 16485
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Playing Sounds on Left Click/Hover

Post by balala »

Eldestbear wrote: May 20th, 2024, 3:13 am It works! When I originally downloaded that sound it was an .mp3 file. I didn't actually convert it, I just renamed the file to be.wav, which in hindsight I realize doesn't do what it should have done. So thanks for that!
I didn't realize that file is in fact a .mp3, but this explains why didn't work. Glad you got it working.
Eldestbear wrote: May 20th, 2024, 3:13 am In regard to all the bans that I can rework or get rid of, that's good to know! I copied a small amount of the coding from other launchers (that are fairly old as you've said), so that's why there's a lot of older code in there. I'll rework it slowly and make those changes!
None of the things I wrote about are mandatory, but are good to be done. Great it's working. Please feel free to come back if further questions arise.