MediaElement.Volume Property
Silverlight
Gets or sets the media's volume.
Namespace: System.Windows.Controls
Assembly: System.Windows (in System.Windows.dll)
<MediaElement Volume="double"/>
Property Value
Type: System.DoubleThe media's volume represented on a linear scale between 0 and 1. The default is 0.5.
Dependency property identifier field: VolumeProperty
Volume can be difficult to quantify because each media file has a different baseline for its recorded or perceived audio level. Also, true audio volume as represented on the decibel scale is inherently logarithmic. You can think of the Volume property as representing the position value of an audio mixer slider control, with 0 being all the way down and 1 being all the way up.
Platform Notes
Silverlight for Windows Phone
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.
NB: The Volume and IsMuted properties don't work unless the MediaElement is added to the Visual Tree
See the discussion here: http://forums.silverlight.net/forums/p/184264/419579.aspx
In effect, if you simply new-up a MediaElement, and play stuff through it, everything will play fine, but the Volume and IsMuted properties won't work when you try to set them through code. You have to do something like this to get them to work:
LayoutRoot.Children.Add(mediaElement);
mediaElement.Visibility = Visibility.Collapsed;
- 4/9/2011
- Ken Smith