简体   繁体   English

Windows Phone 8.1滑块中的音量级别不变

[英]The volume level doesn't change in a windows phone 8.1 slider

I am trying to change the valume of the phone while song is playing. 我正在尝试在播放歌曲时更改手机的valume。
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. 但是,当我使用滑块时,它只会在音乐为零时关闭音乐,否则将其关闭,但不会改变音量。

Note that, the volume range is 0~1. 注意,音量范围是0〜1。 You must divide slider value by slider maximum. 您必须将滑块值除以滑块最大值。

BackgroundMediaPlayer.Current.Volume = (double)VolumeSlider.Value/VolumeSlider.Maximum; 

MediaElement volume range 0-1. MediaElement的音量范围是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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM