HTML5<音频>淡入淡出和淡出播放 [英] HTML5 <audio> playback with fade in and fade out

查看:150
本文介绍了HTML5<音频>淡入淡出和淡出播放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在随机位置启动和停止HTML5播放,淡入和淡出阶段以平滑聆听体验。



存在哪种机制为了这?用setTimeout()手动增加音量?

解决方案

jQuery方式...

  $ audio.animate({volume:newVolume},1000); 

编辑:其中$ audio是jQuery包装的音频元素,newVolume是0和1之间的双精度值。编辑:元素的有效媒体音量是音量,相对于0.0到1.0的范围进行解释,其中0.0是无声的,1.0是最大声的设置,值之间的值响度增加。范围不必是线性的。 http://www.w3.org/html/ wg / drafts / html / master / embedded-content.html#effective-media-volume

I'd like to start and stop HTML5 playback in a random position with fade in and fade out periods to smooth the listening experience.

What kind of mechanisms exists for this? Manually ramp up the volume with setTimeout()?

解决方案

The jQuery way...

$audio.animate({volume: newVolume}, 1000);

Edit: where $audio is a jQuery-wrapped audio element and newVolume is a double between 0 and 1.

Edit: The element's effective media volume is volume, interpreted relative to the range 0.0 to 1.0, with 0.0 being silent, and 1.0 being the loudest setting, values in between increasing in loudness. The range need not be linear. http://www.w3.org/html/wg/drafts/html/master/embedded-content.html#effective-media-volume

这篇关于HTML5<音频>淡入淡出和淡出播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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