Skip to content
A Javascript Sound API supporting MP3, MPEG4 audio and video formats, providing reliable cross-browser/platform audio control. BSD licensed.
Find file
Pull request Compare This branch is 8 commits ahead, 1100 commits behind scottschiller:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
custom
demo
doc
script
src
swf
troubleshoot
.gitignore
README.rdoc
build.xml
index.html
license.txt

README.rdoc

SoundManager 2

SoundManager 2 makes it easier to play sounds using Javascript.

By wrapping and extending the Flash sound API, SoundManager 2 brings solid audio functionality to Javascript.

Changes

This version adds support for streaming using RTMP (and its variants) from a Flash Media Server (or similar). Our company has a requirement to stream over RTMPe so I have implemented changes to support this goal, while making things generic enough for others to use as well. This should work for FMS/FMIS/etc, and all RTMP* protocols, but YMMV.

Having delved deeply into the code implementing these changes I would recommend FlowPlayer for RTMP. The code looks excellent and very modular. SoundManager2 is a great product but the code makes extending its features rather difficult.

If your FMS server supports a getStreamLength call you can use that to get the length of the music stream. However, this isn't being used at the moment because our FMS server mis-reports stream lengths.

To use these features you must:

  • Use the Flash 9 soundmanager2_flash9.swf

  • Enable the global useMovieStar option

  • Pass isMovieStar = true in your options to createSound

  • Pass a value for serverUrl in your options to createSound. This will be the URL for the FMS server.

  • Use the soundmanager2.js JavaScript file. I've also generated a no-debug version soundmanager2-nodebug.js.

New options to createSound:

  • serverUrl URL for the FMS server

  • onconnect callback called when the connection to the server is made

  • totalBytes total size of the file in bytes

  • duration duration of the song in seconds

  • onfailure duration of the song in seconds

Example

soundManager.flashVersion = 9;
soundManager.useMovieStar = true;

var options = {
  id: 1234,
  url: 'mp3:01_Shes_Like_The_Wind',
  serverUrl: 'rtmpe://your.fms.server/path/to/song/directory/',
  isMovieStar: true,
  autoPlay: true,
  autoLoad: true,
  onconnect: self.onConnect,
  whileplaying: self.updateSongPosition,
  onfinish: self.onFinish,
  onbeforefinish: self.queueNextSong,
  onplay: self.showPlayingAndResetPlayStatRecorded,
  onpause: self.showPaused,
  onresume: self.showPlaying,
  whileloading: self.showLoadingProgress,
};
return self.sm.createSound(options);

Debugging

  1. Set

    soundManager.debugFlash = true;
  2. Generate a debug version of the SWF

    make-flash9-debug.sh
  3. Open the Flash IDE. Open the SM2 source code files. Start a remote debugging session.

  4. Refresh the application in the browser (make sure caching is off)

  5. The SWF should connect to Flash and allow you to step through the source.

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

* Full-screen MPEG-4 video (HE-AAC/H.264) and 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

A few nifty sites that have implemented SoundManager 2 for driving audio:

* Muxtape
* SoundCloud / The Cloud Player
* 8tracks

Project home, documentation, live demos etc.: www.schillmania.com/projects/soundmanager2/

Something went wrong with that request. Please try again.