JS的语音控制库:SoundManager2
jopen
10年前
SoundManager2 是一个 JavaScript 语音 API,对HTML5 和 Flash Audio APIs进行了封装和扩展。 支持MP3, MPEG4 和HTML5 audio + (experimental) RTMP。它为JavaScript提供了可靠的跨浏览器的语音控制,体积很小,只有 11KB 左右。
HTML5 Audio() Support
* 100% Flash-free MP3 + MP4/AAC where supported * Compatible with Apple iPad 3.2, iPhone/iOS 4 and newer * Fallback to Flash for MP3/MP4 support, as needed * SM2 API is transparent; HTML5/flash switching handled internally * HTML5 API support approximates Flash 8 API features * Some other formats (WAV/OGG) supported via HTML5, depending on browser * See "useHTML5Audio" property for implementation details
Basic API Features (Flash 8)
* Load, stop, play, pause, mute, seek, pan and volume control of sounds from Javascript * Events: onload, whileloading, whileplaying, onfinish and more * ID3V1 and ID3V2 tag support for MP3s (title, artist, genre etc.)
Shiny Flash 9 Features
* RTMP / Flash Media Server streaming support (new, experimental) * MPEG-4 (AAC, HE-AAC, H.264) audio support * "MultiShot" play (layered/chorusing effects) * Waveform/frequency spectrum data * Peak (L/R channel volume) data * Audio buffering state/event handling
General Tech Stuff
* Full API Documentation with examples and notes * console.log()-style debug output and troubleshooting tools * Community-based discussion/support
As Heard On The Internets
A few nifty sites that have implemented SM2 for driving audio:
* Songza * Earbits * freesound.org * last.fm * 8tracks * Discogs * The Hype Machine * nyan.cat * AudioGalaxy