HTML音频标签音量 [英] HTML audio tag volume

查看:954
本文介绍了HTML音频标签音量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



音频来源是一个在线流媒体热链接。

 <音频自动播放> 
< source src =http://lel.com/link/to/stream.m3u>
< / audio>

我已经设法做到了这一点,并且运行良好。



现在我想调低流的音量,因为音频应该留在背景中,招待参观者,而不是因响度而让他们耳癌。



我已经搜索了论坛,但我总是找到解决方案来调整视频的音量。



我也搜索了音频标签的参数,但似乎没有音量标签的音量参数。



哦,不要担心合法性。
我用于网站的信息流没有版权,我可以在我的网站上使用它。



快速回复将不胜感激!
Thanks,CC!

解决方案

浏览器不支持Theres no volume属性,因此您必须在JavaScript中设置volume属性

 < audio autoplay id =myaudio> 
< source src =http://lel.com/link/to/stream.m3u>
< / audio>

< script>
var audio = document.getElementById(myaudio);
audio.volume = 0.2;
< / script>

请参阅 http://jsfiddle.net/sjmcpherso/6r1emoxq/


I embedded a background audio into my website which autoplays on visit.

The source of the audio is a online stream hotlink.

<audio autoplay>
      <source src="http://lel.com/link/to/stream.m3u">
    </audio>

I already managed to do that and its working well.

Now i want to turn down the volume of the stream because the audio should just stay in the background and entertain the visitors instead of giving them ear cancer due to loudness.

I already searched the forums but i always found solutions for turning the volume of a video.

I also searched for the parameters of the audio tag but there seems no volume parameter for the audio tag.

Oh and don't worry about legalities. The stream i use for the website has no copyright and i am permitted to use it on my website.

A quick response would be appreciated! Thanks, C.C.!

解决方案

Theres no volume attribute supported by browsers so you must set the volume property in JavaScript

<audio autoplay id="myaudio">
  <source src="http://lel.com/link/to/stream.m3u">
</audio>

<script>
  var audio = document.getElementById("myaudio");
  audio.volume = 0.2;
</script>

See http://jsfiddle.net/sjmcpherso/6r1emoxq/

这篇关于HTML音频标签音量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆