Multiple Players
Not just one player on a website
Overview
Multiple players can be included on one web page.
The players are completely separated from each other and each one can have its own playlist and design.
It is quite simple. Add a class
or id
to each player and use the querySelector()
method to select each player
individually.
Everything else remains the same.
Code example
Notice:
Set the preset
attribute with the setAttribute()
method in JavaScript - NOT in the
frissbee-audio-player
HTML tag.
The reason for this is that the player (the frissbee-audio-player
HTML tag) is loaded first and the player does not know your custom
preset name at this time, which is loaded later. So the custom preset must be set after the frissbee-audio-player
HTML tag is loaded.
The order is important!
player.customPresets
player.setAttribute()
player.playlist