zoukankan      html  css  js  c++  java
  • SoundManager 2 实现web页面中嵌入声音播放

    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. 

    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 the url and 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

    Once soundManager.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.

     
  • 相关阅读:
    【开源】知乎日报UWP 更新
    【开源】知乎日报UWP 更新
    耿丹学院软工助教(2016年上半年)
    c++ STL map 结构体
    2016搜狐笔试二叉树和最大的子树
    从B树、B+树、B*树谈到R 树
    C++继承:公有,私有,保护
    循环队列
    C++中的static关键字
    c++map的用法
  • 原文地址:https://www.cnblogs.com/boonya/p/2960630.html
Copyright © 2011-2022 走看看