I am working with a waveform display/play library called wavesurfer. In the snippet that I created below, I have two such wavesurfer objects rendered and placed inside "container" type div elements. I would like to place my own rectangle over one of these wavesurfer objects, and control it's position using javascript.
My problem is I do not want to use absolute coordinates referenced for the browser window. I want to use relative coordinates based on the position within the wavesurfer object. Furthermore, as you can see, the rectangle is not overlayed over the waveform, even if I place it within the same div container.
I am new to javascript and realize that this could be a very basic question about overlaying shapes on top of things like pictures, but so far I haven't been able to find a solution that works for the waveform objects I am working with.
var wavesurfer = WaveSurfer.create({
container: "#waveform",
waveColor: "darkorange",
progressColor: "skyblue",
interact: false
});
wavesurfer.load("https://ia902606.us.archive.org/35/items/shortpoetry_047_librivox/song_cjrg_teasdale_64kb.mp3");
var wavesurfer2 = WaveSurfer.create({
container: "#waveform2",
waveColor: "silver",
progressColor: "gainsboro",
interact: false
});
wavesurfer2.load( "https://ia902606.us.archive.org/35/items/shortpoetry_047_librivox/song_cjrg_teasdale_64kb.mp3"
);
<body>
<script src="https://unpkg.com/wavesurfer.js"></script>
<script src="https://unpkg.com/wavesurfer.js/dist/wavesurfer.min.js"></script>
<script src="https://unpkg.com/wavesurfer.js/dist/plugin/wavesurfer.regions.min.js"></script>
<div class="container" style="display: flex">
<div id="waveform" style="width:60%"></div>
</div>
<div class="container" style="display: flex">
<div id="waveform2" style="width:60%"></div>
</div>
<div>
<input type="range" id="slider" name="range_slider" min="0" max="11">
<label for="range_slider">Range Slider</label>
</div>
<div id="selector">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<rect x="10" y="10" width="50" height="100" stroke="black" stroke-width="5" fill="none" />
</svg>
</div>