SoundManager 2 实现web页面中嵌入声音播放
2013-03-15 00:12
246 查看
reference:http://www.schillmania.com/projects/soundmanager2/
SoundManager 2 makes it easier to play audio using JavaScript.
features:Using HTML5 and Flash, SoundManager 2 provides reliable cross-platform audio under a single JavaScript API.
Getting started is pretty easy, too.
SoundManager 2 gives you a single, powerful API that supports both new and old, using HTML5 audio where supported and optional Flash-based fallback where needed. Ideally when using SoundManager 2, audio "just works."
Performance is an important metric, too. SoundManager 2 packs a comprehensive, feature-rich API into as little as11 KB over the wire when optimized; that's less than 8% of the original, uncompressed file size.
The source code is BSD-licensed and is provided in fully-commented, non-debug and compiler-optimized "minified" versions appropriate for development and production use.
Upon execution of soundmanager2.js, SM2 will determine what Flash SWF to load (if any) based on the path defined in
After successful initialization,
By default, SM2 uses a Flash 8-based SWF build. Some additional features are available when using the Flash 9-based build.
For a live example, see the basic template demo.
Additional options and events can be specified when loading and playing sounds. For more examples of playback features, see API Demos.
SoundManager 2 makes it easier to play audio using JavaScript.
features:Using HTML5 and Flash, SoundManager 2 provides reliable cross-platform audio under a single JavaScript API.
Speak and be heard
More sound, in more places
Despite being one of the senses, sound has largely been missing from the web due to inconsistent technology support. SoundManager 2 bridges this gap, making it easier to use audio across a growing variety of devices and platforms, both desktop and mobile.Getting started is pretty easy, too.
HTML5 + flash hybrid
Complexity, reduced
Supporting HTML5 audio can be tedious in modern browsers, let alone legacy ones. With real-world visitors using browsers ranging from mobile Safari to IE 6 across a wide range of devices, there can be many support cases to consider.SoundManager 2 gives you a single, powerful API that supports both new and old, using HTML5 audio where supported and optional Flash-based fallback where needed. Ideally when using SoundManager 2, audio "just works."
The ginsu knife: 11 KB*
Big features, small footprint
But wait, there's more!Performance is an important metric, too. SoundManager 2 packs a comprehensive, feature-rich API into as little as11 KB over the wire when optimized; that's less than 8% of the original, uncompressed file size.
The source code is BSD-licensed and is provided in fully-commented, non-debug and compiler-optimized "minified" versions appropriate for development and production use.
Basic
Playable links and playlists
These demos use unordered lists with MP3 links that play in-place; the UI is easily customized via CSS.Shiny
Data visualization features
The 360° player UI demo uses <canvas> and includes options for waveform and spectrum analysis data via Flash 9, adding beautiful visual feedback to the interface.Experimental
Advanced prototypes
The Cassette Tape UI is a skinnable player based on the TDK MA-R90 cassette tape, a classic design from 1982.Getting started
Basic SoundManager 2 set-up
Including the script, configuring theurland registering an
onready()callback:
<script src="soundmanager2.js"></script> <script> soundManager.setup({ // where to find flash audio SWFs, as needed url: '/path/to/swf-files/', onready: function() { // SM2 is ready to play audio! }) }); </script>
Upon execution of soundmanager2.js, SM2 will determine what Flash SWF to load (if any) based on the path defined in
soundManager.url.
After successful initialization,
soundManager.onready()will fire and sounds can be played.
By default, SM2 uses a Flash 8-based SWF build. Some additional features are available when using the Flash 9-based build.
For a live example, see the basic template demo.
Playing audio
Basic playback control
OncesoundManager.onready()has fired, sounds can be loaded and played.
Creating and playing a sound object
// create "mySound"... soundManager.createSound({ id: 'mySound', url: '/path/to/an.mp3' }); // ...and play it soundManager.play('mySound');
Additional options and events can be specified when loading and playing sounds. For more examples of playback features, see API Demos.
相关文章推荐
- Android如何让WebView中的HTML5页面实现视频全屏播放
- Android WebView页面结束后视频播放还有声音问题处理
- RTMP与Flowplayer实现web页面视频流播放功能
- webview 加载h5页面,播放视频+全屏,实现简单封装
- Android WebView页面结束后视频播放还有声音问题
- 建立第一个directX程序——在C#下利用DirectSound实现声音播放
- CCF问题集合3:嵌入WEB页面弹出子页面,丢失session的问题
- EasyDSS高性能流媒体服务器前端重构(五): webpack + vue-router 开发单页面前端实现按需加载
- 在html中嵌入flash对象实现flv播放
- web页面实现指定区域打印功能
- Web 播放声音 — Flash 篇 (播放 AMR、WAV)
- ASP.NET页面嵌入视频播放
- Jquery实现视频播放页面的关灯开灯效果
- 建立第一个directX程序——在C#下利用DirectSound实现声音播放
- 在C#中利用DirectX实现声音播放
- 【转】Web页面导出标准的Excel/Word/txt的代码实现
- Android Webview中解决H5的音视频不能自动播放、只有声音没有图像的问题
- 微信开发之移动手机WEB页面(HTML5)Javascript实现一键拨号及短信发送功能
- WinCE系统播放wav声音文件的实现方法
- Web页面实现打印功能