XWidgetSoft Forum
https://bbs.xwidget.com/

Help with volume icon
https://bbs.xwidget.com/viewtopic.php?f=8&t=2028
Page 1 of 1

Author:  zequi [ August 25th, 2012, 10:28 pm ]
Post subject:  Help with volume icon

Hi, I have no idea how to code but for the past few days I've been modifying other people widgets to create my own set

Image

As you can see, they're not very good looking :? but incredibly useful to me since they rest upon the taskbar (as topmost) and can be accessed at any time.
Anyways, my question is, is there a way to make the volume icon change depending of the volume percentage or if it's muted? if there's such an option I couldn't find it...
if you can show me a template it would be awesome.

Thanks for your help and excuse my poor english :oops:

Edit: Also, is there a way to make the mail core to play a sound when new mail arrives?

Author:  vlad [ August 30th, 2012, 2:07 am ]
Post subject:  Re: Help with volume icon

Try this out - http://4ybak47.deviantart.com/art/Round ... -324235369

(And the source file available to download from that link)

To enable the onClick sound change - go to your button -> Attributes -> Binding Core -> volumecore1
Then in your button's -> Functions -> OnClick :: type "!DownVolume=20" or "!UpVolume=5". (The 5 & 20 are the value which the volume is going to be changed by).

The main idea of changing the image corresponding to the core, is to have all the different images available and visible -> hide them on start and each time the value changes, hide all the images and then show only one that matches your value.

Code:
//This function called when the volume is being updated.
function volCoreOnUpdate(Sender)
{
         //Hide all the volume images.
         imgMuted.Visible = false;
         imgLow.Visible = false;
         imgMed.Visible = false;
         imgMax.Visible = false;


         //Display image



         //Display muted image if the volume is muted or the volume is equale to zero.
         //if (volCore.Volume == 0 || volCore.IsMute )
         //On my conputer properity IsMute is not supported, try it on yours by replacing the following string whith the provius one.
         if (volCore.Volume == 0)
         {
              imgMuted.Visible = true;
         }

         //Display full volume if its over 80
         else if (volCore.Volume >= 80)
         {
              imgMax.Visible = true;
         }

         //Display normal volume if its over 40 and below 80
         else if (volCore.Volume >= 40)
         {
              imgMed.Visible = true;
         }

         //Else if the volume is not muted and below 40 show low volume image
         else
         {
              imgLow.Visible = true;
         }

}


The imgMuted, imgLow, imgMed and imgMax are the images

Attachments:
File comment: Widget preview
VolumeControl.png
VolumeControl.png [ 13.37 KiB | Viewed 8762 times ]

Author:  zequi [ August 30th, 2012, 4:38 am ]
Post subject:  Re: Help with volume icon

Thank you so much vlad!! this is exactly what I wanted.
if (volCore.IsMute) didn't work for me either, though. It's a shame cause it was so close to be perfectly functional...

Again, you're a genius man. I wish I could come up with this stuff by myself.

Do you have any idea about my other question? I think the mail core without a sound warning is kind of incomplete. Maybe there's an easy way and I'm missing it.

Author:  vlad [ August 31st, 2012, 1:56 am ]
Post subject:  Re: Help with volume icon

Well if u r using the mailCore there is a value valled %Count which represents the amount of emails you have right now, my idea is to save the amount of email you haven't read and on each update (make it 20 - 30 min) check if the amount has been increased or not. If so play a sound and notify the user about an incoming mail.

So you should define a variable "started" onLoad, then u will have to add another one called mailAmount initially we will define it as zero
Code:
function onLoad()
{
     started =  false;
     mailAmount = 0;
}


Add an event to the mail core onUpdate so we can compare the amount of email which had been added from the last time u had checked the mail count.
Code:
function mailCoreOnUpdate()
{
     if ( mailAmount < mailCore.Count)
     {
          playSound();
          showSomeSexyAnimation();
     }

     //Update the mail amount for further compares
     mailAmount = mailCore.Count;
}


The code is not perfect, it will always play sound each time you start your computer or add this widget. And I haven't played yet with this core so im not sure what happen's when u actually read the email. If the amount just drops so that code should work fine, but if not tell me and ill try to figure it out.

Author:  zequi [ August 31st, 2012, 2:36 am ]
Post subject:  Re: Help with volume icon

Thank you so much for taking your time to answer.
I'm sorry but , can you make me a template like the last time? I know it's really simple but I can't do it.
Last time for example, when I tried to copy your code into my widget, nothing happened. then I modified yours doing the same stuff I did in mine and it worked perfectly. There's something I'm not doing right...
If you can't don't worry about it, you've been helpful enough.

Author:  vlad [ August 31st, 2012, 6:33 am ]
Post subject:  Re: Help with volume icon

Example of playing sounds:
http://4ybak47.deviantart.com/#/d5d622k

I dont know how to work with the MailCores, if could send me the template u made i could view the way it works. Or just tell me how to set up the user name and password for the gMailCore

Author:  zequi [ August 31st, 2012, 6:58 am ]
Post subject:  Re: Help with volume icon

This is my widget (don't laugh).

Attachments:
mail.zip [57.81 KiB]
Downloaded 397 times

Author:  Tony [ September 1st, 2012, 12:50 am ]
Post subject:  Re: Help with volume icon

zequi wrote:
is there a way to make the mail core to play a sound when new mail arrives?


Hi, You can uses function "PlaySound( filepath )" in script,etc:

you need put the "a.wav" sound file into the widget folder,and when image1 clicked,write code:

Code:
function image1OnClick(Sender)
{
  PlaySound("a.wav");
}

Author:  vlad [ September 1st, 2012, 6:43 am ]
Post subject:  Re: Help with volume icon

Listen Tony i tried the PlaySound("a.wav") function but apparently it only works with "wav" files (i used a mp3 file) , maybe its only on my PC the function PlaySound() and PlaySound2() wont work for mp3's, in further release could u make a PlayMp3(...file) ?.

zequi your sound is now playing when new mail is arriving, download the example below.

Attachments:
mail.zip [57.71 KiB]
Downloaded 411 times

Author:  zequi [ September 1st, 2012, 5:10 pm ]
Post subject:  Re: Help with volume icon

Thank you so much vlad!! you're my hero.
I swear from now on I will not be bothering you that much ;)

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/