HTA。如何淡出嵌入的音乐 mp3(重新加载)
我真的需要一些帮助,在所有示例中,我发现淡出效果依赖于“音频 id”元素:
<audio id="myAudio">
<source src="./LZ.mp3" type='audio/mp3'>
</audio>
在所有情况下,我的 HTA 都不会播放任何声音 看来我只能使用“embed”甚至“bgsound”方法
但随后我迷失了应用所需的淡出功能
以下代码是我用来与 mp3 音乐文件一起启动启动画面的简化 Hta 脚本。
<html>
<head>
<script language="vbscript">
winWidth=350
winHeight=90
window.resizeto winWidth,winHeight
centerX=(screen.width-winWidth)/2
centerY=(screen.height-winHeight)/2
</script>
</head>
<head>
<HTA:APPLICATION
ID="start"
VERSION="2.0"/>
<body>
<button style=" title="">Starting </button> <p>
</body>
</head>
<script type="text/javascript">
function countdown() {
var i = document.getElementById('start');
{
window.close();
}
}
setInterval(function(){ countdown(); },30000);
</script>
<body>
<embed audio src="./LZ.mp3"></audio >
</body>
</html>
水花将持续 30 秒。关闭时会切断声音 我想在 25 秒后(结束前 5 秒)添加淡出效果
(我无法将淡出效果直接应用于 mp3 文件,因为很快使用另一个脚本我可以选择使用任何其他 mp3)
音乐将自动启动,淡出效果应该是自动的(我的意思是没有手动按钮)
编辑:感谢 LesFerch,我的简化 hta 现在正在播放 + 音乐正在以目标淡出效果关闭。我只是想再次添加“开始”标题和颜色效果:
<body>
<button style= title="">Starting Firefox</button> <p>
<script language="VBScript">
Dim Intrval, direction
Dim c 'Used to increment
Function Color(i) : Color = "#" & Hex(i) & Hex(ii) & Hex(i) : end function
Sub Window_Onload
c = &hff
direction = -2
Intrval = setInterval("changeColor", 20)
end sub
sub changeColor
document.body.bgColor = Color(c)
c = (c + direction)
if c > (&hff - Abs(direction)) or c < Abs(direction) then direction = -direction
end sub
</script>
I really need some help IN All the examples I found the fade out effect was relying on the "audio id" element :
<audio id="myAudio">
<source src="./LZ.mp3" type='audio/mp3'>
</audio>
in all cases my HTA will not play any sound
It seem I can only use the "embed" or even the "bgsound" method
but then I'm lost on applying the needed fade out functions
The following code is the simplified Hta script I use to start a splash together with the mp3 music file.
<html>
<head>
<script language="vbscript">
winWidth=350
winHeight=90
window.resizeto winWidth,winHeight
centerX=(screen.width-winWidth)/2
centerY=(screen.height-winHeight)/2
</script>
</head>
<head>
<HTA:APPLICATION
ID="start"
VERSION="2.0"/>
<body>
<button style=" title="">Starting </button> <p>
</body>
</head>
<script type="text/javascript">
function countdown() {
var i = document.getElementById('start');
{
window.close();
}
}
setInterval(function(){ countdown(); },30000);
</script>
<body>
<embed audio src="./LZ.mp3"></audio >
</body>
</html>
The splash will last 30 secs. and on closing will cut the sounds
I would like to add a fade out effect after 25 secs (5 secs. before the end)
(I cannot apply the fade out effect directly to the mp3 file because very quickly using another script I can chose to use any other mp3 )
the music will auto-start and the fade out effect should be automatic ( I mean no manual buttons)
EDIT: thanks to LesFerch my simplified hta now is playing + the music is closing with the aimed fade out effect. I'm just trying to add again the "Starting" title and the colors effects:
<body>
<button style= title="">Starting Firefox</button> <p>
<script language="VBScript">
Dim Intrval, direction
Dim c 'Used to increment
Function Color(i) : Color = "#" & Hex(i) & Hex(ii) & Hex(i) : end function
Sub Window_Onload
c = &hff
direction = -2
Intrval = setInterval("changeColor", 20)
end sub
sub changeColor
document.body.bgColor = Color(c)
c = (c + direction)
if c > (&hff - Abs(direction)) or c < Abs(direction) then direction = -direction
end sub
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用重复链接中的答案,我进行了一些调整以消除
IndexSizeError
,在没有按钮的情况下播放 mp3,并使淡入淡出持续合理的时间。由于您的示例代码以 VBScript 开始,因此我假设这是您的首选语言。如果没有,我也可以发布 JScript 版本。注意:这也许不重复的原因是,对于 HTA,必须声明文档模式并将其设置为 IE=9 或更高版本。
注意:文档模式 IE=9 及更高版本更区分大小写。例如,
screen.availWidth
将起作用,screen.AvailWidth
将抛出错误。Using the answer in the duplicate link, I made some adjustments to eliminate an
IndexSizeError
, play the mp3 without a button, and make the fade last a reasonable amount of time. Since your sample code starts off in VBScript, I've assumed that's your preferred language. If not, I can post a JScript version as well.Note: What makes this, perhaps, not a duplicate is that, for an HTA, the document mode must be declared and set to IE=9 or higher.
Note: Document mode IE=9 and higher are much more case sensitive. For example,
screen.availWidth
will work,screen.AvailWidth
will throw an error.