37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
/******/ (() => { // webpackBootstrap
|
|
/*!**********************************!*\
|
|
!*** ./src/audio-player/view.js ***!
|
|
\**********************************/
|
|
/**
|
|
* Initializes Plyr audio player on the front-end
|
|
* Note: Plyr is loaded as a dependency via PHP (see audio-player.php)
|
|
*/
|
|
|
|
// Initialize Plyr on all audio elements with the js-plyr class
|
|
document.addEventListener("DOMContentLoaded", () => {
|
|
// Check if Plyr is available (loaded via PHP)
|
|
if (typeof Plyr === "undefined") {
|
|
/* eslint-disable no-console */
|
|
console.error("Plyr library not loaded");
|
|
/* eslint-enable no-console */
|
|
return;
|
|
}
|
|
const players = Array.from(document.querySelectorAll(".js-plyr")).map(element => new Plyr(element, {
|
|
controls: ["play-large", "play", "progress", "current-time", "duration", "mute", "volume", "settings"],
|
|
settings: ["speed"],
|
|
speed: {
|
|
selected: 1,
|
|
options: [0.5, 0.75, 1, 1.25, 1.5, 2]
|
|
}
|
|
}));
|
|
|
|
// Optional: Log players for debugging
|
|
if (players.length > 0) {
|
|
/* eslint-disable no-console */
|
|
console.log("Plyr audio players initialized:", players.length);
|
|
/* eslint-enable no-console */
|
|
}
|
|
});
|
|
/******/ })()
|
|
;
|
|
//# sourceMappingURL=view.js.map
|