maciejzasada / flashGetUserMedia

Provides WebRTC getUserMedia fallback via Flash plugin for browsers that do not support getUserMedia natively.
7 stars 2 forks source link

flashGetUserMedia

Provides WebRTC getUserMedia() fallback via Flash plugin for browsers that do not support getUserMedia() natively.

Usage

flashGetUserMedia.init({swfPath: 'flashGetUserMedia.swf', force: false});
navigator.getUserMedia({audio: true, video: false}, successHandler, failureHandler);

Options

Example implementation

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <script type="text/javascript" src="https://github.com/maciejzasada/flashGetUserMedia/raw/master/vendor/recorder.js"></script>
    <script type="text/javascript" src="https://github.com/maciejzasada/flashGetUserMedia/raw/master/flashGetUserMedia.js"></script>
</head>
<body>

<script>

    var audioContext, mediaStreamSource, recorder;

    function onGetMediaSuccess(source) {

        mediaStreamSource = audioContext.createMediaStreamSource(source);
        setTimeout(function () {
            record();
        }, 1);

    }

    function onGetMediaFail() {

        console.log('media fail handler');

    }

    function record() {

        recorder = new Recorder(mediaStreamSource);
        recorder.record();

    }

    function stopAndPlay() {

        recorder.stop();
        recorder.exportWAV(function(s) {

            var audio = document.createElement( 'audio' );
            audio.src = window.URL.createObjectURL(s);
            audio.id = 'record';
            document.body.appendChild(audio);
            audio.play();

        });

    }

    flashGetUserMedia.init({swfPath: 'flashGetUserMedia.swf', force: true});

    audioContext = new AudioContext();
    navigator.getUserMedia({audio: true, video: false}, onGetMediaSuccess, onGetMediaFail);

</script>

</body>
</html>

Project Status

v. 0.1 (28/06/2013)