Author Topic: Volume Lock  (Read 6694 times)

Mayibongwe

  • Sr. Member
  • ****
  • Posts: 1733
  • Heal The World
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.
Strength and Honour (2025)

gaiastar

  • Full Member
  • ***
  • Posts: 244
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
MusicBee is the best audio player ever made, Love it ♫♫

Mayibongwe

  • Sr. Member
  • ****
  • Posts: 1733
  • Heal The World
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.
Strength and Honour (2025)

gaiastar

  • Full Member
  • ***
  • Posts: 244
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
MusicBee is the best audio player ever made, Love it ♫♫

Mayibongwe

  • Sr. Member
  • ****
  • Posts: 1733
  • Heal The World
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.
Strength and Honour (2025)

Mayibongwe

  • Sr. Member
  • ****
  • Posts: 1733
  • Heal The World
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.
Strength and Honour (2025)

hiccup

  • Hero Member
  • *****
  • Posts: 9111
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...

Mayibongwe

  • Sr. Member
  • ****
  • Posts: 1733
  • Heal The World
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.
Strength and Honour (2025)

BoringName

  • Sr. Member
  • ****
  • Posts: 916
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))

gaiastar

  • Full Member
  • ***
  • Posts: 244
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
MusicBee is the best audio player ever made, Love it ♫♫

Mayibongwe

  • Sr. Member
  • ****
  • Posts: 1733
  • Heal The World
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.
Last Edit: July 16, 2024, 05:27:09 PM by Mayibongwe
Strength and Honour (2025)

gaiastar

  • Full Member
  • ***
  • Posts: 244
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
MusicBee is the best audio player ever made, Love it ♫♫

Mayibongwe

  • Sr. Member
  • ****
  • Posts: 1733
  • Heal The World
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.
Strength and Honour (2025)

slonopot

  • Jr. Member
  • **
  • Posts: 95
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

Mayibongwe

  • Sr. Member
  • ****
  • Posts: 1733
  • Heal The World
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.
Strength and Honour (2025)