<!-- Works with background-image too -->
<divclass="float-imgplay"style="background-image:url('/images/sky.jpg');
width:320px; height:320px;
background-size:cover;">
</div>
<!-- Also works on img directly -->
<imgclass="float-imgplay"src="/images/photo.jpg"width="320"height="320">
const player = newFloatImgPlay({
selector: '.float-imgplay',
autoplay: false
});
player.init();
// Register a specific element with different optionsconst hero = document.querySelector('#hero-image');
player.register(hero, {
autoplay: true,
audio: {
waveform: 'sawtooth',
masterVolume: 0.5,
pitchShiftSemitones: 3,
tempo: 132,
scaleMode: 'minor'
}
});
const player = newFloatImgPlay({
selector: '.float-imgplay'
});
player.init();
// Play a specific element
player.play(document.querySelector('#my-image'));
// Stop a specific element
player.stop(document.querySelector('#my-image'));
// Pause (alias for stop)
player.pause(document.querySelector('#my-image'));
// Re-analyze after image src changes
player.refresh();
// Remove a single element
player.unregister(document.querySelector('#my-image'));
// Clean up everything
player.destroy();