Sample-Polymer



Simply import the element

              
                    <script type="text/javascript" src="../bower_components/platform/platform.js"></script>
                    <link rel="import" href="bower_components/sample-polymer/audio-pad.html" />
                </head>
                <body>
                    <div class="container">
                        <audio-pad></audio-pad>
                    </div>
              
            

...and pass your element an audio context and the url to your sample after the 'polymer-ready' event has fired.

              
                window.addEventListener('polymer-ready', function(evt) {
                  var pad = document.querySelector('audio-pad');
                  var audioContext = generateAudioContext();
                  pad.audioContext = audioContext;
                  pad.url = 'path/to/your/sample.wav';

                  // preload the sound without playing
                  pad.loadSilent();

                  // play the sound
                  pad.play();
                }
              
            
Fork me on GitHub