On my server I use Audiowaveform to generate JSON data from my audio files.
On frontend I use Wavesurfer-JS to draw the waveform based on previous JSON data.
The problem is that on page ready the Wavesurfer-JS download on background the audio file all the time (and not only when the user hit the play button).
This is my try.
This is the salient part:
<div id="waveform">
<audio id="song" style="display: none" preload="false" src="http://api.soundcloud.com/tracks/45398925/stream?client_id=fa791b761f68cafa375ab5f7ea51927a"></audio>
</div>
<script>
var wavesurfer = WaveSurfer.create({
container: '#waveform',
waveColor: 'grey',
backend: 'MediaElement',
mediaType:'audio',
progressColor: 'red',
cursorColor: '#fff',
normalize: true,
barWidth: 3
});
wavesurfer.load(document.querySelector('#song'), ['.$json.']);
</script>
So basically I need to focus on wavesurfer.load
and add a new function to this Javascript to only draw from peaks(JSON data) the waveform and don't download audio file on page load but only when the user hit the play button.
How can I achieve it?