laurentvd / wavesurfer.swf

Flash fallback for wavesurfer.js
MIT License
24 stars 12 forks source link

wavesurfer.swf

Flash fallback for wavesurfer.js

Note: This repository is now archived and readonly. No one should use Flash anymore and my knowledge of ActionScript has withered away :)

Goal

The purpose of wavesurfer.swf is to bring as many wavesurfer.js functionalities as possible to browser that do not support WebAudio or Canvas. It does this by mimicking the js version in Flash, using the same API.

Browser support

Any browser that runs Flash. It was originally built to support IE9 - IE11 which all lack the required WebAudio support.

Requirements

Wavesurfer.swf has no requirements apart from wavesurfer.js! However, we use SWFObject in the demo to embed the SWF.

How to use

Please refer to the demo folder for an example on how to implement wavesurfer.swf. Keep in mind that you cannot view the Flash version when running from your local disk. You need to run this demo on a webserver. This is a Flash security restriction.

The API is similar to the js version, although not all methods and configuration options are supported at the moment. Here's a very brief example:

var wavesurfer = new WaveSurfer.Swf('myFlashContainerid');

// ... embed the SWF on the page using any method you like

// Wait for the swf to initialize
wavesurfer.on('init', function() {

    // Initialize with your own configuration object
    wavesurfer.init({
        waveColor: '#999999',
        ...
    });

    // And load the mp3 file
    wavesurfer.load('Rick_Astley.mp3');
});

For more examples, please refer to the readme of wavesurfer.js.

API

Not all of the wavesurfer.js is currently supported. Below you'll find a list of everything that's supported.

Supported WaveSurfer Options

option type default description
cursorWidth integer 1 Measured in pixels.
cursorColor string #333 The fill color of the cursor indicating the playhead position.
progressColor string #555 The fill color of the part of the waveform behind the cursor.
waveColor string #999 The fill color of the waveform after the cursor.
backgroundColor string #fff The fill color of background.

Supported WaveSurfer Methods

Supported WaveSurfer Events

Credits

Original Javascript version by katspaugh and others!