Reputation: 123
I am trying to change the valume of the phone while song is playing.
I did that:
BackgroundMediaPlayer.Current.Volume = (double)VolumeSlider.Value;
but, when I use the slider, it only turns music off when its on zero, and on otherwise, but it doesnt change the level.
Upvotes: 0
Views: 279
Reputation: 6178
MediaElement volume range 0-1. So, you should set the slider value within this range.
<Slider Name="VolumeSlider"
Background="White"
Foreground="Red"
Minimum="0"
Maximum="1"
SmallChange="0.1"
LargeChange="0.2"
Value ="0.5" />
BackgroundMediaPlayer.Current.Volume = (double)VolumeSlider.Value;
Upvotes: 0
Reputation: 11
Note that, the volume range is 0~1. You must divide slider value by slider maximum.
BackgroundMediaPlayer.Current.Volume = (double)VolumeSlider.Value/VolumeSlider.Maximum;
Upvotes: 1