Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does HTML5 make sound on Web?

2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how HTML5 makes sound on Web". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how HTML5 makes sound on Web".

An example of HTML5 making sound on Web

Here is an example of creating sound independently and controlling the sound to be emitted and stopped under Web conditions

The code is as follows: (please browse using Firefox version 4.0 or later)

Generate audio

Function playTone () {

Var output = new Audio ()

Output.mozSetup (1, 44100)

Var samples = new Float32Array (22050)

Var len = samples.length

For (var I = 0; I < samples.length; iTunes +) {

Samples [I] = Math.sin (I / 30)

}

Output.mozWriteAudio (samples)

}

When you press the button below, the demo will dial the tone for one second.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report