Partager via


VOLUME Attribute | volume Property

This topic documents a feature of HTML+TIME 2.0, which is obsolete as of Windows Internet Explorer 9.

Sets or gets the volume of the media file.

Syntax

HTML <ELEMENT VOLUME = iVol... >
Scripting [ iVol = ] object.volume

Possible Values

iVol Variant that specifies or receives the volume of the media file, relative to its parent element. The value specified in iVol is converted to a Floating-point number. Valid values range from 0 to 100.
0
Audio is turned off completely.
100
Default. Audio plays at full volume.

The property is read/write. The property has a default value of 100.

Remarks

You can control the volume of all elements in a time container, such as a par element or a seq element, by setting the volume property on the time container element. To control the volume of all the media on the page, set the volume of the body element.

The volume is relative to its parent element; therefore, if the volume of the parent element is set to 50, and the volume of the child element is set to 50, the effective volume of the child element is 25.

When you use Microsoft DirectMusic, the volume property is implemented as a global property of the DirectMusic player; it is not specific to any individual segment. Because of this, the lowest segment element in the page controls the volume level of all of the segment elements. In the following example, the volume level of oSegment1 is zero because the lowest segment element ( oSegment2 ) has its VOLUME attribute set to zero.

<!-- The effective volume of this element is zero even though it is set to
100. This is because the lowest segment element is set to zero.-->
<t:AUDIO VOLUME="100" ID=oSegment1 PLAYER=dmusic SRC="sample.sgt"/>
<t:AUDIO VOLUME="0" ID=oSegment2 PLAYER=dmusic SRC="sample2.sgt"/>

Example

The following example allows you to select the volume of the sound effect, or turn off the volume entirely.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML XMLNS:t="urn:schemas-microsoft-com:time">
<HEAD>
<TITLE>volume / mute Property</TITLE>
<?IMPORT namespace="t" implementation="#default#time2">

<STYLE>
    .time{ behavior: url(#default#time2);}
</STYLE>
</HEAD>

<BODY>

<t:media id="m1" begin="indefinite;"
    src="/workshop/samples/author/behaviors/media/shuttle3.wmv"
    onmediacomplete="Timer2.beginElement();" fill="remove"/>

<BR><BR>
<BUTTON id="b0" onclick="m1.beginElement();">Start</BUTTON>
<BUTTON id="b3" onclick="m1.endElement();">Stop</BUTTON>
<BR><BR>

<B>Volume control:</B>&nbsp;
<input type="radio" name="i1" onpropertychange="m1.mute='true';">Mute
<input type="radio" name="i1"
    onpropertychange="m1.mute='false';m1.volume=25;">25% Volume
<input type="radio" name="i1"
    onpropertychange="m1.mute='false';m1.volume=50;" checked>50% Volume
<input type="radio" name="i1"
    onpropertychange="m1.mute='false';m1.volume=75;">75% Volume
<input type="radio" name="i1"
    onpropertychange="m1.mute='false';m1.volume=100;">100% Volume

</BODY>
</HTML>

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/behaviors/volume_mute.htm

Applies To

t:ANIMATION, t:AUDIO, t:IMG, t:MEDIA, t:PAR, t:REF, t:SEQ, time2, t:VIDEO

See Also

Introduction to HTML+TIME, mute