carhop__plugins__PROD-DEV/plugins/carhop-blocks/blocks/audio-player/build/audio-player/view.js
Antoine M 8c5ce525da
All checks were successful
continuous-integration/drone/push Build is passing
UPDATE Refactor audio player block to adjust control order in Plyr initialization and update asset versioning
2025-10-30 09:45:40 +01:00

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