Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change System Volume in WinRT

I have a volume slider in my WinRT app which I would like to sync with the system volume. Is there a way to do this? iOS allows developers to give this functionality.

like image 337
Elmo Avatar asked Dec 13 '25 12:12

Elmo


2 Answers

The volume of playback can be controlled using the MediaElement.Volume property. I cannot find a specific supporting quote but my own observations indicate the volume is per MediaElement object like it is in SilverLight and there is no way to change the system volume in an app.

like image 178
akton Avatar answered Dec 15 '25 00:12

akton


The volume of playback can be controlled using the MediaElement.Volume property as this property is a double value between 0 and 1.

You can use a slider to control the volume in this case you do:

private void slider_ValueChanged(object sender, RangeBaseValueChangedEventArgs e)
{
    if(mute)
    {
        MediaElement.IsMuted = false;
        mute = false;
        MediaElement.Volume = (slider.Value)/100;
    }
    else
    {
        MediaElement.Volume = (slider.Value) / 100;
    }
}

The mute variable is of Boolean data-type that controls whether the sound is cut or not

like image 32
mokmap Avatar answered Dec 15 '25 00:12

mokmap



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!