Old 1st June 2006, 21:51   #1
JW
Senior Member
 
Join Date: Nov 2004
Location: Valencia, CA
Posts: 304
Volume control fun

My volume control buttons are doing something odd. More often than not, I can turn the volume all the way up to 100%, then it will start over again at 0%. I can do the same thing going down. The volume will usually go through three complete 0-100 cycles before it stops, and then it will stay between 0 and 100 and not roll over.

PHP Code:
VolDown.onLeftClick()
{
  if (
AutoRepeat_ClickType != 0)
  {
    if (
CurrentVolume 0//I added this in, thinking it would not let it go past 0
    
{
      
CurrentVolume CurrentVolume 2.55;
      
System.SetVolume(system.integer(CurrentVolume));
    }
  }
}

VolUp.onLeftClick()
{
  if (
AutoRepeat_ClickType != 0)
  {
    if (
CurrentVolume 255//Same thing here
    
{
      
CurrentVolume CurrentVolume 2.55;
      
System.SetVolume(system.integer(CurrentVolume));
    }
  }

JW is offline   Reply With Quote
Old 1st June 2006, 22:10   #2
Canadian_Dude
Senior Member
 
Join Date: Feb 2006
Location: Alberta, Canada
Posts: 104
Quick question kinda off topic but, is it possible to do while statements in maki?
Canadian_Dude is offline   Reply With Quote
Old 2nd June 2006, 00:19   #3
Michgelsen
Major Dude
 
Michgelsen's Avatar
 
Join Date: Oct 2003
Location: Netherlands
Posts: 1,416
Quick answer kinda off topic, I haven't had any success with that yet.

On topic, are you refreshing that CurrentVolume value often enough? It looks to me like the "if(currentvolume > 0)" just stays at a certain value, such as "if(4 > 0)".
Maybe you could try to use getVolume() there.

Another possibility is to save the value of the volume each time it is set to a new value (to let's say "int oldvolume"). That way you can compare the new value to the previous value and thus decide whether the volume should update or not.
Michgelsen is offline   Reply With Quote
Old 2nd June 2006, 00:49   #4
TheElusiveMelon
Senior Member
 
TheElusiveMelon's Avatar
 
Join Date: Feb 2005
Location: Kent, England
Posts: 350
I had the same problem in a skin i am working on. Basically i made a function that updates the volume. The function takes one parameter from the buttons, which is 1 or 2 depending if the button is for up or down.

Then in the function i have:

So num = 1 is for volume up, and num = 2 if for volume down

if ((num == 1)&&(currentvolume >= 255)) return;
if ((num == 2)&&(currentvolume <= 0 )) return;

This way it exits the function without doing anything, so it makes the buttons only work where needed. So if you press volume up when the volume is on 100%, it does nothing.

If you cant get it from here, just say and i will upload a simplified version of my code which should work.
TheElusiveMelon is offline   Reply With Quote
Old 2nd June 2006, 03:09   #5
JW
Senior Member
 
Join Date: Nov 2004
Location: Valencia, CA
Posts: 304
Quote:
Originally posted by Michgelsen
On topic, are you refreshing that CurrentVolume value often enough? It looks to me like the "if(currentvolume > 0)" just stays at a certain value, such as "if(4 > 0)".
Maybe you could try to use getVolume() there.
Perfect! Thanks!
JW is offline   Reply With Quote
Old 2nd June 2006, 15:23   #6
JW
Senior Member
 
Join Date: Nov 2004
Location: Valencia, CA
Posts: 304
Well, almost. Still runs over occasionally, now only when going up.
JW is offline   Reply With Quote
Old 2nd June 2006, 16:54   #7
Michgelsen
Major Dude
 
Michgelsen's Avatar
 
Join Date: Oct 2003
Location: Netherlands
Posts: 1,416
That's not so weird actually. Imagine that volume is set to 254. That's smaller than 255, so the function is allowed to continue. Then it adds 2.55, which means it would be 256.55. Therefore it will run over.
Michgelsen is offline   Reply With Quote
Old 2nd June 2006, 17:51   #8
rohan_pwln
Major Dude
 
rohan_pwln's Avatar
 
Join Date: Aug 2002
Location: 18 inches from hell
Posts: 736
for making a while loop, use a for loop like this:

for(;condition;) {
//your code goes here
}

The condition is what you'll put in between the '(' and ')' for the while loop.

My MAKI contribs.: STONE
My WebSite My Blog My Skins: fnk 32 Rioport v1 Sienna Burning Steel
My Saying: Eat healthy, Stay fit... Die Anyway
rohan_pwln is offline   Reply With Quote
Old 2nd June 2006, 18:11   #9
JW
Senior Member
 
Join Date: Nov 2004
Location: Valencia, CA
Posts: 304
I didn't think about that, because in theory the volume level should always be some multiple of 2.55. But, based on what you said, I did this and it works:

PHP Code:
VolUp.onLeftClick()
{
  if (
AutoRepeat_ClickType != 0)
  {
    if (
System.getVolume() > 252.45)
    {
      
CurrentVolume 255;
      
System.SetVolume(system.integer(CurrentVolume));
    }
    else
    {
      
CurrentVolume CurrentVolume 2.55;
      
System.SetVolume(system.integer(CurrentVolume));
    }
  }

JW is offline   Reply With Quote
Old 2nd June 2006, 20:16   #10
Michgelsen
Major Dude
 
Michgelsen's Avatar
 
Join Date: Oct 2003
Location: Netherlands
Posts: 1,416
When the user only alters the volume with your buttons, then in theory yes, but with the scroll wheel or the (global hot)keys it's possible that a different value is set.
Michgelsen is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Skinning and Design > Modern Skins

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump