getmusicbee.com

MusicBee & Add-Ons => Customizations => Plugins => Topic started by: Mayibongwe on June 09, 2024, 02:14:45 AM

Title: Volume Lock
Post by: Mayibongwe on June 09, 2024, 02:14:45 AM
Download it from the add-on link here (https://getmusicbee.com/addons/plugins/506/volume-lock/)

Any way/chance of locking the volume control?
Could it be done as a plugin?
Above is the link to the thread that made me give this a go just to see if it'd be possible.
Looks to be working just fine in my brief testing.

(https://i.imgur.com/HzeMDfA.png)
Title: Re: Volume Lock
Post by: cciss on June 10, 2024, 04:17:23 AM
Thankyou!!!
"works a treat"
Title: Re: Volume Lock
Post by: Tony_D on June 17, 2024, 10:58:19 PM
Thank you for the pug-in  8)

Tony D.
Title: Re: Volume Lock
Post by: gaiastar on June 30, 2024, 04:11:30 PM
Hi Mayibongwe
another nice plugin
do you think it could start at a value definite by the user and changed but the users just moving the volume slider?

for example , start musicbee with volume always set at 30% and increase moving only the sliders?
thanks
Title: Re: Volume Lock
Post by: Mayibongwe on July 01, 2024, 05:22:49 PM
do you think it could start at a value definite by the user and changed but the users just moving the volume slider?

for example, start musicbee with volume always set at 30% and increase moving only the sliders?
Hi gaiastar. I'm not sure l understand.
The idea behind the plugin was to disable the volume slider when ever the plugin was enabled.
Leaving the slider active would defeat the purpose of locking the volume, I think.
Title: Re: Volume Lock
Post by: gaiastar on July 01, 2024, 05:48:43 PM
do you think it could start at a value definite by the user and changed but the users just moving the volume slider?

for example, start musicbee with volume always set at 30% and increase moving only the sliders?
Hi gaiastar. I'm not sure l understand.
The idea behind the plugin was to disable the volume slider when ever the plugin was enabled.
Leaving the slider active would defeat the purpose of locking the volume, I think.
hi
i know
I would like to ask you if could possibile to setup to start musicbee always at 30% volume , in short a low value, or a custom value
thanks
Title: Re: Volume Lock
Post by: Mayibongwe on July 01, 2024, 05:55:44 PM
I would like to ask you if could possibile to setup to start musicbee always at 30% volume , in short a low value, or a custom value
I may still be misunderstanding, so bear with me:
In the preferences (refer to my screenshot above), you are able to manually type in the volume percentage in order to permanently lock it at that level.
Is that not what you require?
Title: Re: Volume Lock
Post by: gaiastar on July 01, 2024, 06:20:57 PM
I would like to ask you if could possibile to setup to start musicbee always at 30% volume , in short a low value, or a custom value
I may still be misunderstanding, so bear with me:
In the preferences (refer to my screenshot above), you are able to manually type in the volume percentage in order to permanently lock it at that level.
Is that not what you require?
hi
i would like to start musicbee at volume 30% and after increase how i like it
in short only start musicbee at  a low volume for my ears ...
thanks
Title: Re: Volume Lock
Post by: Mayibongwe on July 01, 2024, 06:29:19 PM
Ah, I see what uu mean now.
I can add a checkbox in the preferences with something like "startup only" where if ticked, would only set that volume at startup only.
I'll probably do that the coming weekend if I make the time.
Title: Re: Volume Lock
Post by: gaiastar on July 01, 2024, 06:32:07 PM
Ah, I see what uu mean now.
I can add a checkbox in the preferences with something like "startup only" where if ticked, would only set that volume at startup only.
I'll probably do that the coming weekend if I make the time.
hi
thank you!
Title: Re: Volume Lock
Post by: Mayibongwe on July 07, 2024, 08:20:33 AM
The above request has now been implemented - get the update on the same download link.
(https://i.imgur.com/7dIA8Er.png)
Title: Re: Volume Lock
Post by: gaiastar on July 07, 2024, 03:07:55 PM
The above request has now been implemented - get the update on the same download link.
(https://i.imgur.com/7dIA8Er.png)
hi Mayibongwe
well i have setup the plugin to be  locked at 5% , but when i start musicbee it does start to platy at 100%
i think it's iusse and should be fixed
but thanks
Title: Re: Volume Lock
Post by: Mayibongwe on July 07, 2024, 03:14:26 PM
Can you share a screenshot of your preferences like my screenshot above?
And just to rule off a mis-match in the way I've handled the plugin database on this update:
Can you go to ...\appData\mb_volumeLock\... and delete the files in there, then restart MusicBee.
Title: Re: Volume Lock
Post by: gaiastar on July 07, 2024, 03:35:12 PM
Can you share a screenshot of your preferences like my screenshot above?
And just to rule off a mis-match in the way I've handled the plugin database on this update:
Can you go to ...\appData\mb_volumeLock\... and delete the files in there, then restart MusicBee.
hi Mayibongwe
I don't know why i can't post some screenshots in this forum by few days
well first screenshot
1)
plugin settings
first screenshot (https://imgur.com/a/STV5tOg)

2)
volume when i musicbee it does start at 100%
second screenshots (https://imgur.com/a/j8wJDXO)

activity.log
Quote
Initial volume @ 0,5058824
Initial startup @ True
Shutting down: MusicBeeClosing

settings.txt
Quote
Locked @ 0,5058824
Startup only @ True

thanks
Title: Re: Volume Lock
Post by: Mayibongwe on July 07, 2024, 03:48:07 PM
Yep, something weird is going on. I messed up somewhere.
Lemme look at this, I will come back to you.
Title: Re: Volume Lock
Post by: Mayibongwe on July 07, 2024, 04:58:06 PM
I am not sure what to make of this.
The same plugin file available for download (which is hosted on my personal computer) is working as expected on that pc with MB v3.6.8698
I have downloaded the same file on my work computer with MB v3.6.8869 and it's exhibiting the same weird behaviour you described.

I shall take a closer look at this with a fresh brain during the week. It shouldn't really matter what MB version is in use.
Title: Re: Volume Lock
Post by: gaiastar on July 07, 2024, 05:00:04 PM
Yep, something weird is going on. I messed up somewhere.
Lemme look at this, I will come back to you.
hi Mayibongwe
ok , may i ask you a question?
does the plugin store only settings on a separate file ini ?
just to perform a clean install , i will click on uninstall ,yes?
thanks
Title: Re: Volume Lock
Post by: Mayibongwe on July 07, 2024, 05:04:17 PM
yes, uninstalling the plugin will delete the folder...\appData\mb_volumeLock\...and its contents.
But I've tried a reinstall of this plugin on this work pc, and it hasn't made a difference. It's quite strange.
But yes, you can try a reinstall.
Title: Re: Volume Lock
Post by: gaiastar on July 07, 2024, 06:14:14 PM
yes, uninstalling the plugin will delete the folder...\appData\mb_volumeLock\...and its contents.
But I've tried a reinstall of this plugin on this work pc, and it hasn't made a difference. It's quite strange.
But yes, you can try a reinstall.
hi Mayibongwe
well i don't need to backup AppData or MusicBee3Settings.ini or MusicBeeLibrarySettings.ini , do I ?
the plugin doesn't store anything on these files right?
i'm asking because the plugin could be really cool , just think start musicbee with the volume at 10% and maybe even with a fade (but i guess fading only with we start musicbee could not be done)
but thanks  for the plugin  ♥
Title: Re: Volume Lock
Post by: Mayibongwe on July 07, 2024, 06:25:09 PM
well i don't need to backup AppData or MusicBee3Settings.ini or MusicBeeLibrarySettings.ini , do I ?
the plugin doesn't store anything on these files right?
i'm asking because the plugin could be really cool , just think start musicbee with the volume at 10% and maybe even with a fade (but i guess fading only with we start musicbee could not be done)
Nope, rest assured. I do not touch those or anything outside of ...AppData\mbVolumeLock
Starting MusicBee with a predefined volume level is the change I introduced in the latest update - which works on one of my machines and not the other, for some weird reason.
I just have to figure out why and then I will let uu know.
Title: Re: Volume Lock
Post by: Mayibongwe on July 15, 2024, 05:39:26 PM
I am not sure what to make of this.
The same plugin file available for download (which is hosted on my personal computer) is working as expected on that pc with MB v3.6.8698
I have downloaded the same file on my work computer with MB v3.6.8869 and it's exhibiting the same weird behaviour you described.

I shall take a closer look at this with a fresh brain during the week. It shouldn't really matter what MB version is in use.
Gaiastar, if you re-download the plugin, it should work as expected now.

Turns out the oversight was due to my work pc (which runs on W11) saving the actual volume with a comma for the decimal portion - which i suspect was the case with you too.
On the other hand, my personal computer which I use to code, and runs on W10, was only saving the decimals with a full-stop.
I've added something to cater for both worlds.

I know this has generally come up in MusicBee before (probably in the skinning section, if i recall well), where commas worked for some people/regions and wouldn't work for some.
Anyway, it's all good now.
Title: Re: Volume Lock
Post by: hiccup on July 15, 2024, 06:00:26 PM
I know this has generally come up in MusicBee before (probably in the skinning section, if i recall well), where commas worked for some people/regions and wouldn't work for some.
You recall well.

And it's funny that you mention this now, since only a couple of days ago I found out that most of my uploaded skins had much larger position/duration digits then how I originally designed them to be.

At first I couldn't understand why, but then I found out that the cause was dot vs. comma here also.
( in id="TrackPosition" parent="TrackInfoPanel" fontSize="9.00"> )

In the past when I created these skins my Windows localisation setting must have been different from when I last uploaded updates of them.
These kind of unexpected trip-ups are easy to miss...
Title: Re: Volume Lock
Post by: Mayibongwe on July 15, 2024, 06:33:12 PM
At first I couldn't understand why, but then I found out that the cause was dot vs. comma here also.
( in id="TrackPosition" parent="TrackInfoPanel" fontSize="9.00"> )
Yep! Now that you mention it, that's the topic I had in mind.
I sometimes think about whether or not seasoned developers like Steven and boroda also scratch their heads over minors like this when trying to solve an apparent bug.
Title: Re: Volume Lock
Post by: BoringName on July 15, 2024, 11:12:39 PM
I wouldn't say I'm a seasoned developer but I had issues with decimal points and commas in different regions when reading/saving config files.

Using something like this to read/write floats seemed to solve it.
sampleFloat = float.Parse(floatString, System.Globalization.CultureInfo.InvariantCulture);

floatString = sampleFloat.ToString(System.Globalization.CultureInfo.InvariantCulture))
Title: Re: Volume Lock
Post by: gaiastar on July 16, 2024, 04:57:03 PM
At first I couldn't understand why, but then I found out that the cause was dot vs. comma here also.
( in id="TrackPosition" parent="TrackInfoPanel" fontSize="9.00"> )
Yep! Now that you mention it, that's the topic I had in mind.
I sometimes think about whether or not seasoned developers like Steven and boroda also scratch their heads over minors like this when trying to solve an apparent bug.
Hi
it doesn't not work under w10 pro 64bit for me
the volume in the plugin is stuck at 6,352941E+08 , i was thinking about 20%
but when i start musicbee 3.5.8698 portable the volume is at max
thanks
Title: Re: Volume Lock
Post by: Mayibongwe on July 16, 2024, 05:20:56 PM
the volume in the plugin is stuck at 6,352941E+08 , i was thinking about 20%
but when i start musicbee 3.5.8698 portable the volume is at max
If the volume read from the settings file is invalid (i.e. not a number between 0 and 100), I currently have the plugin set to max it instead.

Is the 6,352941E+0 showing up in the preferences window?
Are you saying that, when you manually type "20" in that window, the plugin is writing "6,352941E+08" to its settings file, instead of 0.2 or 0,2?

Edit:
sampleFloat = float.Parse(floatString, System.Globalization.CultureInfo.InvariantCulture);
floatString = sampleFloat.ToString(System.Globalization.CultureInfo.InvariantCulture))
Shot, thanks. I'll experiment with that should the commas and periods still be the issue on gaiastar's side.
So far, I've only worried about reading from the file.
I've left it to the OS to decide how to write the decimal to the file.
It's only the reading back where I've put something to replace a comma with a period, since MusicBee will only accept periods.
Title: Re: Volume Lock
Post by: gaiastar on July 16, 2024, 05:24:58 PM
the volume in the plugin is stuck at 6,352941E+08 , i was thinking about 20%
but when i start musicbee 3.5.8698 portable the volume is at max
If the volume read from the settings file is invalid (i.e. not a number between 0 and 100), I currently have the plugin set to max it instead.

Is the 6,352941E+0 showing up in the preferences window?
Are you saying that, when you manually type "20" in that window, the plugin is writing "6,352941E+08" to its settings file, instead of 0.2 or 0,2?
Hi
Quote
Is the 6,352941E+0 showing up in the preferences window?
yes
Quote
Are you saying that, when you manually type "20" in that window, the plugin is writing "6,352941E+08" to its settings file, instead of 0.2 or 0,2?
yes , whatever i type the volume is always at6,352941E+08
thanks
Title: Re: Volume Lock
Post by: Mayibongwe on July 16, 2024, 05:32:55 PM
I don't know what to think of that for now.
But in the meantime, just go to the settings file in the appData folder and manually change the volume to 0.5.
On restart, that should set Musicbee at 50% volume.
Afterwards, go into the preferences and type in 0.2 to see if it still writes that garbage value.
Title: Re: Volume Lock
Post by: slonopot on July 17, 2024, 09:00:18 PM
I've looked through the code to see if there's anything obvious that may cause such behaviour. Here are my ideas, opinions and suggestions that nobody asked for:

1. Player_GetVolumeDelegate and Player_SetVolumeDelegate operate floats, but newVolume, actualVolume are strings. Unnecessary conversions are just postponed barely detectable issues. Use floats.
2. Storing data in your own format is not a good idea if you can't guarantee that it will work the same way every single time. C# and .NET are heavily system-oriented and have all those different conversions and format styling depending on the region. You may not notice it at first since all these configurations are optional, but you did get a taste of the defaults with dots and commas in float conversions for different regions. If you use complex structures that may fail unexpectedly (even floats), either make sure you save and load them with the same converter (you use Convert.ToString and float.Parse, for example) or just outsource it to something that will figure it out on its own. Write it to a json/xml/ini file with a .net built-in serializer, read with the deserializer and always have your values restored in an expected form.
3. Handle errors. MusicBee will suppress any failures, the user won't notice, but the logic will fail. Just a global try-except with a messagebox for starters will be of a great troubleshooting assistance, logging in file is also an option if you can guarantee that the file is writable and was not messed with by a notepad with admin rights. Just add try-excepts in all major places and display something when an error occurs, you'll be able to troubleshoot it further once it's reported.

It's good overall, just minor patches here and there and you'll receive no alerts from this thread in a long time.

Windows UI in legacy software is always a problem though (https://i.ibb.co/Rb9Vxq0/photo-2024-07-17-22-55-37.jpg)
Title: Re: Volume Lock
Post by: Mayibongwe on July 22, 2024, 04:47:56 PM
Thanks slonopot - that's certainly good advice right there!
Using two data types interchangeably is just delaying the inevitable complications down the line.
#3 is definitely a must, regardless of how small the code is. I shall heed your advice.

Regarding the attached screenshot, what monitor size or dpi scale are you using there?
I will admit that I winged most of the control positioning and didn't necessary use anchor points. I recall it being a headache the last time I worked on a panel plugin.
Title: Re: Volume Lock
Post by: gaiastar on July 22, 2024, 07:53:51 PM
Thanks slonopot - that's certainly good advice right there!
Using two data types interchangeably is just delaying the inevitable complications down the line.
#3 is definitely a must, regardless of how small the code is. I shall heed your advice.

Regarding the attached screenshot, what monitor size or dpi scale are you using there?
I will admit that I winged most of the control positioning and didn't necessary use anchor points. I recall it being a headache the last time I worked on a panel plugin.
hI
may I know where could the plugin updated and fixed?
thanks
Title: Re: Volume Lock
Post by: sveakul on July 22, 2024, 08:25:20 PM
hI
may I know where could the plugin updated and fixed?
thanks
Between this plugin and the several issues/requests Mayibongwe is working on in LyricsReloaded, I wouldn't try to rush the poor guy, when they get fixed they get fixed.
Title: Re: Volume Lock
Post by: sveakul on August 19, 2024, 08:43:48 PM
@gaiastar:  does this newly posted alternative plugin help you at all?

https://getmusicbee.com/addons/plugins/511/link-system-amp-musicbee-volume/ (https://getmusicbee.com/addons/plugins/511/link-system-amp-musicbee-volume/)
Title: Re: Volume Lock
Post by: gaiastar on August 20, 2024, 04:41:10 PM
@gaiastar:  does this newly posted alternative plugin help you at all?

https://getmusicbee.com/addons/plugins/511/link-system-amp-musicbee-volume/ (https://getmusicbee.com/addons/plugins/511/link-system-amp-musicbee-volume/)
hi sveakul
I wanted to reply to the the topic original (https://getmusicbee.com/forum/index.php?topic=15751.0) but it's pretty old
i would like an option to start musicbee with a volume at 20% or 15% ,in short a custom volume setting/value
I think i will wait ,since i guess the author is busy
about the plugin , it doesn't fit for me
Quote
A plug-in that simply links the volume level of MusicBee and Windows Volume Together.
   If you change MusicBee Volume, The System Volume will change also and vice versa.
thanks
Title: Re: Volume Lock
Post by: Mayibongwe on August 22, 2024, 05:44:22 PM
But in the meantime, just go to the settings file in the appData folder and manually change the volume to 0.5.
On restart, that should set Musicbee at 50% volume.
Gaiastar, btw, did you ever attempt to manually override the volume on the plugin's appData folder?