admin管理员组文章数量:1304951
I am using media player to play audio and video. I am creating own button to increase and decrease the volume of the media player. working fine too.
Problem:
Even after reaches 0% volume its audible. If the player volume increase the system volume also be increased. Is it possible. How to achieve this task.
Control:
<object id="mediaPlayer" classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
codebase=".cab#Version=5,1,52,701"
height="1" standby="Loading Microsoft Windows Media Player ponents..."
type="application/x-oleobject" width="1">
<param name="fileName" value="" />
<param name="animationatStart" value="true" />
<param name="transparentatStart" value="true" />
<param name="autoStart" value="true" />
<param name="showControls" value="true" />
<param name="volume" value="70" />
</object>
Code:
function decAudio() {
if (document.mediaPlayer.Volume >= -1000) {
var newVolume = document.mediaPlayer.Volume - 100;
if (newVolume >= -1000) {
document.mediaPlayer.Volume = document.mediaPlayer.Volume - 100;
} else {
document.mediaPlayer.Volume = -1000;
}
}
}
I am using media player to play audio and video. I am creating own button to increase and decrease the volume of the media player. working fine too.
Problem:
Even after reaches 0% volume its audible. If the player volume increase the system volume also be increased. Is it possible. How to achieve this task.
Control:
<object id="mediaPlayer" classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
codebase="http://activex.microsoft./activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"
height="1" standby="Loading Microsoft Windows Media Player ponents..."
type="application/x-oleobject" width="1">
<param name="fileName" value="" />
<param name="animationatStart" value="true" />
<param name="transparentatStart" value="true" />
<param name="autoStart" value="true" />
<param name="showControls" value="true" />
<param name="volume" value="70" />
</object>
Code:
function decAudio() {
if (document.mediaPlayer.Volume >= -1000) {
var newVolume = document.mediaPlayer.Volume - 100;
if (newVolume >= -1000) {
document.mediaPlayer.Volume = document.mediaPlayer.Volume - 100;
} else {
document.mediaPlayer.Volume = -1000;
}
}
}
Share
Improve this question
edited Mar 9, 2010 at 6:16
Eilon
25.7k3 gold badges87 silver badges105 bronze badges
asked Mar 9, 2010 at 6:09
GeethGeeth
5,34323 gold badges86 silver badges136 bronze badges
2 Answers
Reset to default 6if the audio is still audible once document.mediaPlayer.Volume
is set to 0
, why don't you set
document.mediaPlayer.Settings.mute = true
?
also are you sure that document.mediaPlayer.Settings.Volume
isn't the correct reference instead of document.mediaPlayer.Volume
? it looks like you're trying to access the parameter/property value directly instead of going through the mediaplayer's javascript (or jscript) interface.
here's some general reference for you of the "most important" parameters supported by Windows Media Player 7 and later:
obj = document.getElementById("mediaPlayer");
Code
Parameters
or default valueDescription
obj.Settings.autoStart
true
- Specifies or retrieves a value indicating whether the current media item begins playing automatically.
obj.Settings.baseURL
- -
- Specifies the base URL used for relative path resolution with URL script mands that are embedded in media items.
ClosedCaption.captioningID
0
- Specifies the name of the element displaying the captioning.
obj.Controls.currentMarker
0
- Specifies the current marker number.
obj.Controls.currentPosition
0
- Specifies the current position in the media item in seconds.
obj.Settings.defaultFrame
- -
- Specifies the name of the frame used to display a URL.
obj.enableContextMenu
true
- Specifies a value indicating whether to enable the context menu, which appears when the right mouse button is clicked.
obj.enabled
false
- Specifies whether the Windows Media Player control is enabled.
obj.fullScreen
false
- Specifies whether video content is played back in full-screen mode.
obj.Settings.invokeURLs
true
- Specifies a value indicating whether URL events should launch a Web browser.
obj.Settings.mute
false
- Specifies if audio is muted.
obj.Settings.PlayCount
1
- Specifies the number of times a media item will play. Minimum value of one.
obj.Settings.rate
1.0
- Specifies the playback rate. 0.5 equates to half the normal playback speed, 2 equates to twice.
obj.stretchToFit
false
- Specifies whether video displayed by the control automatically sizes to fit the video window, when the video window is larger than the dimensions of the video image.
obj.uiMode
full
- Specifies which controls are shown in the user interface. Possible values: invisible, none, mini, full.
obj.URL
- -
- Specifies the name of the media item to play. You can specify a local filename or a URL.
obj.Settings.volume
- Last setting
- Zero specifies no volume and 100 specifies full volume.
obj.Settings.balance
false
- Set balance between left and right speakers. 0 is egual, -100 is full left and 100 is full right.
obj.windowlessVideo
false
- Specifies or retrieves a value indicating whether the Windows Media Player control renders video in windowless mode. When windowlessVideo is set to true, the Player control renders video directly in the client area, so you can apply special effects or layer the video with text. Supported by Windows Media Player for Windows XP or later.
[Edit: remove references to your code]
Not that I have used MediaPlayer before, but why such negative values? According to this
source, Volume should range from 0-100?? which is pletely intiutive.
But why are you trying to do this in javascript code when there is a built in volume control int the media player??
本文标签: aspnetHow to control the system volume using javascriptStack Overflow
版权声明:本文标题:asp.net - How to control the system volume using javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741795521a2397916.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论