简体   繁体   English

在HTML5中播放音频时的动画

[英]Animation while playing audio in HTML5

I have a flash player programmed by a different team. 我有一个由其他团队编程的Flash Player。 Now I have 1 project where I need to re program that player into HTML5. 现在我有1个项目,我需要将该播放器重新编程为HTML5。 All functions of the flash player looks doable. Flash Player的所有功能看起来都是可行的。 I am just not sure how to show the animation when audio is being played. 我只是不确定在播放音频时如何显示动画。 Eg. 例如。 When beats get high, the animation shows up more when there is a bit silence the animation show up less. 当拍子变高时,动画会显示得更多,而有些寂静时动画会显示得更少。 Could anybody please help me? 有人可以帮我吗?

To get an idea, here is the attached screenshot: 要想出个主意,请看下面的截图:

在此处输入图片说明

With SoundManager2 you can easily access waveform data and make a graphical display with it: 使用SoundManager2,您可以轻松访问波形数据并使用它进行图形显示:

someSoundObject.whileplaying = function() {
  // Move 256 absolutely-positioned 1x1-pixel DIVs, for example (ugly, but works)
  var gPixels = document.getElementById('graphPixels').getElementsByTagName('div');
  var gScale = 32; // draw -32 to +32px from "zero" (i.e., center Y-axis point)
  for (var i=0; i<256; i++) {
    graphPixels[i].style.top = (gScale+Math.ceil(this.waveformData.left[i]*-gScale))+'px';
  }
}

http://www.schillmania.com/projects/soundmanager2/doc/ http://www.schillmania.com/projects/soundmanager2/doc/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM